[Date Prev][Date Next][Subject Prev][Subject Next][ Date Index][ Subject Index]

v3 xpl buffer [was Case change bug workaround]



≪	Annie, did the UD buffer share the 64K that v3 XPL also used? ≫ --Carl

≪	I belive they did share. [...] What seemed to be shared was UD
space and all S/G's--user and XPL. ≫ --Tim

v3 xpl imposes a real Hobson's choice: I often find myself trying
to decide whether to initialize the new s/g I need or lengthen the pgm
by recycling an existing one. I usually do the latter; at worst, if
the pgm gets too long I can make it modular. Best that can be said
is that it's good discipline.

I've lately been using two techniques to reduce xpl length.
One, libraries, is standard fare in high-level languages. The other
is a wildly improbable, stunningly original and effective method
of forming string literals I lifted from Robert Holmgren's code.
I'd never have thought of it myself in several lifetimes.
Proc {is39} from my !.LIB runtime library illustrates both:
	{sv39,{sv10,{ex}NO }{sx10,{is74}+{is12}+{is75}+{is10}}NO }
where {is22}, another library proc, has earlier saved guillemets as
{is74} and {is75}.

To illustrate proc {is39} at its simplest, say you had a pgm you wanted
to end at one label, with various msgs for various circumstances. Each
situation would s/g a msg before jumping to the end label ...
	{sv12,duh}{GLx}
or
	{sv12,ok}{GLx}
... etc. After performing whatever common routines at {LBx}, the pgm would:
	{sv10,PR}{sx12,{is10}+{is12}}{lb_$LITERAL}{pv39}{pv10}{ex}
{pv39} forms the appropriate {PRompt}, {is10} displays it.

In a more complex application, after one of my pgms collects a one-char
CMline arg or {rc}--initially {is12}--these two calls to {pv39} allowed
me to lop off 2K of lookup tables:
	{sv13,sx00,}{sv53,is}{lb
	}{sx12,{is13}+{is74}+{is53}+{is12}+{is75}}{gl_$LIT}{lb
or
	}{sv13,sx}{sv53,,}{sv54,is00}{lb
	}{sx12,{is13}+{is12}+{is53}+{is74}+{is54}+{is75}}{lb
	}{lb_$LIT}{pv39}{pv10}
I.e., {pv10} = {sx00,{is[unknown]}} or {sx[unknown],{is00}}, where
[unknown] is the char {is12} grabbed. Bravo, Holmgren!

Proc {is34} also calls {is39}, and offloads {is39}'s {is10} as for loop
{is44}. After a call to proc {is34}, if {is84} meets the condition
arg {is44} declared, for loop {is44} performs proc {is54}, increases
or decreases the value of {is84} by the factor arg {is12} declared,
and loops. Usage ([o|] = ascii 13):

	{sx86,{va$ws}}{if{pv86}==1}{lb
		}{lb_FOR}{sv84,1}{lb
		}{sv44,>0}{lb
		}{sv12,-1}{lb
		}{sv54,BF {gt44}[o|]}{lb
		}{pv34}{pv44}{lb
	}{ei}

If a file is open, that proc {is54} prints the loop's code to screen.
The step and condition values are fixed till {is34} is invoked again,
but loop {is44} as is can be recalled reinitialized and with a different
proc {is54}:
	{sx86,{va$ws}}{if{pv86}==1}{lb
		}{lb_FOR}{sv84,4}{lb
		}{sv54,TF {gt44}[o|]{if{pv84}>1}PP XD RP {ei}NO }{lb
		}{pv44}{lb
	}{ei}

Oh, yeah--the print-out ...
	{lb4}{if{pv84}>0}{pv54}{sx84,{pv84}-1}{gl4}{ei}{ex}NO

... and proc {is34}--
	{sv34,{sv10,if{pv84}}{sx44,{is75}+{is74}+{is10}+{is44}+{is75}}{lb
	}{sv10,sx84,{pv84}}{sx12,{is74}+{is10}+{is12}+{is75}+{is74}}{lb
	}{sv10,{pv54}}{sx12,{is44}+{is10}+{is12}}{sv10,gl4}{sv44,ei}{lb
	}{sx12,{is12}+{is10}+{is75}+{is74}+{is44}}{lb
	}{sv10,lb4}{sx12,{is10}+{is12}}{pv39}{sx44,{is10}}{sv10,}NO }
--a good example of recycling variables lengthening code.

Just wanted to see how C language loops would look as xpl procs.
while and do loop procs are similar, and the loops can be nested--
i.e., while in for, etc., but not while in while. Nesting while in while
would just be a matter of hand-coding proc {is45}--
	{lbW}{if{pv85}>0}{pv55}{glW}{ei}{ex}NO
	(obviouly, proc {is55} must change {is85}'s value)
--as a different variable with different variable components. Etc. 	--a

============================= adpFisher  nyc