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

Re: RE Parsing with XS



** Reply to message from Patricia M Godfrey  on Sat, 18 Oct
2003 17:30:07 -0400

> isn't there a difference ... between the kinds of things
> that can be saved with each, as well as what gets done with them?

Patricia, think of the commands as members of sets.

The "stupid" set -- mostly for use with string literals -- consists of SV, SU,
IS, and GT.
The "smart" set -- mostly for evaluation -- consists of SX, PV, and VA. These
three chameleons do a lot of different, and potentially very powerful, things.

 The following have rigid usages.
SV saves *string literals* into the designated numeric variable (e.g. 01). SV
 doesn't do anything else. SV has no manipulative powers.
 
  <=="2" saved as a string, not as a number
  <==content of S/G 01 is "6/3" (an alphanumeric $tring, NOT a
calculation)
IS references ("quotes", so to speak, literally) within an SX command the
complete content of a Save/Get
SU is a string literal which contains a SUbroutine
GT runs a preestablished SUbroutine, or puts a string in text

The following have dynamic uses.
SX interprets (evaluates) the data it contains.
  <==2 saved as a number
 > <==S/G 01 stores the content of system variable VA$DG, e.g.
"D:\XY4\XY4.DLG"
  <==value of S/G 01 is 2
  <==force SX to accept a string literal
  <==S/G 02 holds "BillBrown" (concatenation)
 +> <==S/G 01 holds "WildBillBrown" (concatenation)
 
 
 /> <==value of S/G 01 is 4 (6*2/3=4)
 and so much more...
VA is a souped-up form of IS, with unique capabilities but also some
limitations that IS doesn't have. VA can evaluate almost all XyWrite
variables, including _user_ variables (Save/Gets) and _system_ variables (VAs).
GT and PV are the executive counterparts of, respectively, SV|SU and SX. SV,
SU, and SX are the only commands that can _create_ user variables (Save/Gets).
GT and PV execute, evaluate, and interpret Save/Gets.

GT [GetText] is "stupid": it just puts string literals in text, or executes
code (SUbroutines) robotically -- and does those things very quickly. It is a
handler -- it contains nothing itself, but simply acts upon the designated S/G.
If you code , the string "Wild" is inserted by GT03 into the
current text window at the current CursorPosition (aka ).

PV [PutValue] mainly _acts_ by interpreting (or executing) the content of the
designated Save/Get. PV is "smart": it's the agent of most XPL magic. PV
does more than mere numeric calculation.

Here's a simple example. Suppose we put function BC BlankCommandline in S/G 01:
;*; Puts the literal function "BC " in text, just as "PFUN BC"
does
;*; Blanks the command line
Quite a difference!

There's a section of CTRLCHAR.TXT called "Differences Between PV and GT" which
bears directly on your question. (Regrettably, some of the examples in
CTRLCHAR.TXT use Xy3 tricks that simply don't work in Xy4, and generally are
superceded by simple devices in Xy4 -- which is, let's face it, so much more
powerful than Xy3, it's just obtuse to maintain otherwise. I believe Carl
began, and maybe finished, a Xy4 XPL manual, which is a pretty daunting
undertaking -- it may be available online somewhere, I'm not sure.)

There's no way to define these purposes and usages neatly. The best way to
learn is to experiment, make mistakes, crash XyWrite a lot, and ask questions
when you hit a wall. The most interesting thing about XPL is that you can bend
it out of all shape, and make it do the most extraordinary things -- stretching
the definitions above. I often find myself thinking, "No way did Erickson ever
dream of using XPL in this fashion." Yet what he did dream is so far beyond
the ordinary purposes to which XPL is put, it just boggles my mind sometimes.
For a silly old DOS word processor, it's so bloody clever!

Here's an example. There's a command that *nobody* (to my knowledge) ever used
(prior to U2), with this syntax:
 
A real world example makes more sense:
 
Suppose OED.INI contains the line "INSTALL_PATH=L:\OEDv3\", and you code
>;*;
S/G 01 now contains "L:\OEDv3\". With one economical gesture, you swoop into
an external file (without CAlling it!) and snatch a specific $tring from it.
Nifty. (This procedure underpins XYWWWEB.REG.)

-----------------------------
Robert Holmgren
holmgren@xxxxxxxx
-----------------------------