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

Re: xpl programming



Reply to note from "Morris Krok"  Sun, 1 Jun
2003 12:05:56 -0700

> As I wish to have a better understanding of XPL xy4dos logic, I
> would like to know the use of "+" after VA(FP)

It chains the two strings together, i.e., appends a carriage return
to the d:\path\filename of the file in the current window. The
equivalent in Xy3 is:

XPLeNCODE v2.0
b-gin [UNTITLED]
{<}SX01,{<}VA$FP{>}{>}{<}SV02,[cr|lf]{>}{<}SX01,{<}IS01{>}+{<
}IS02{>}{>}[cr|lf][cr|lf]
-nd
XPLeNCODE


> and also the purpose of | in the if statement

I'm not sure what I was thinking (if anything) when I wrote that IF,
but it can be simplified as shown below. Also, the RS command is
out of place without a prefatory ABort command. Try the following
instead (substitute SAve for STore if you prefer):

XPLeNCODE v2.0
b-gin [UNTITLED]
{<}SX01,{<}VA$FP{>}+"[cr|lf]"{>}[TF_][YD_][DL_]{<}SV02{>}[DB_
][YD_]{<}IF@upr({<}IS02{>})<>{<}IS01{>}{>}{<}GT01{>}{<}EI{>}[
BX_]st[Q2_]{<}EX{>}[cr|lf][cr|lf]
-nd
XPLeNCODE

To answer your question, the vertical bar "|" acts as a separator,
much as it does in a SEarch command, SE |string|. We often use it
as a shorthand to test whether a Save/Get consists of any one of a
number of possible strings. For example, the following is the
conventional way to test whether Save/Get 01 consists of any of the
(case-sensitive) strings "RED" or "GREEN" or "BLUE":

XPLeNCODE v2.0
b-gin [UNTITLED]
;*; (1) Conventional test for string equality (identity)[cr|l
f]{<}IF{<}IS01{>}=="RED"!{<}IS01{>}=="GREEN"!{<}IS01{>}=="BLU
E"{>}. . .{<}EI{>}[cr|lf]
-nd
XPLeNCODE

The separator method save 9 bytes -- and is faster by a factor of
about 20 percent (recall that the Ascii-240 operator means
"contains"):

XPLeNCODE v2.0
b-gin [UNTITLED]
;*; (2) Same as (1), using Ascii-240 containment with separat
or:[cr|lf]{<}IF"|RED|GREEN|BLUE|"{240}("|"+{<}IS01{>}+"|"){>}
{046} . .{<}EI{>}[cr|lf]
-nd
XPLeNCODE

The separators "|" on both sides of the Ascii-240 containment
operator ensure that the IF statement returns FALSE when S/G 01
consists of a mere substring, like "ED" or "REE" or "LU", rather
than the entire string "RED" or "GREEN" or "BLUE". Without the
separator, statement (2) is emphatically NOT the equivalent of
statement (1).

There's nothing sacrosanct about "|". The separator can be any
character not contained in S/G 01. (Again, compare the SEarch
command separator usage.)

Finally, it's worth noting that the parens around the concatenation
("|"+{<}IS01{>}+"|") are required. Editor completely misinterprets
the statement without them.

--
Carl Distefano
cld@xxxxxxxx
http://users.datarealm.com/xywwweb/