[Date Prev][Date Next][Subject Prev][Subject Next][
Date Index][
Subject Index]
Re: Question on VA@ parsing
- Subject: Re: Question on VA@ parsing
- From: cld@xxxxxxxx (Carl Distefano)
- Date: Sat, 17 Apr 2004 18:10:01 -0400
Reply to note from Harry Binswanger Sat, 17 Apr 2004
14:20:15 -0400
> But just plugging in the variable doesn't seem to work. I
> tried:
>
> >>
>
> where 01 is the loop's index counter.
Nice try, Harry, but, as you saw, you can't just plunk in a variable
after the separator. A (literal) number is required. To get a number
into that position, and to increment it on each pass through a loop,
you need to manufacture the VA@ statement by concatenation and use the
PV operator to evaluate the concatenation each time. Like this
(PSEUDO-code):
;*;
;*;
;*;
+1>+">">>;*;
{>}0>;*;
>
Here's the same in real XPL. To run it, issue DECODE, DeFine
the resulting block of code and issue RUNCODE:
XPLeNCODE v2.0
b-gin [UNTITLED]
{<}SV44,RED|GREEN|BLUE|YELLOW{>};*;[cr|lf]{<}SX01,0{>};*;[cr|
lf];*;[cr|lf]{<}LBa{>}{<}SX01,{<}PV01{>}+1{>}{<}SX02,"{<}VA@4
4|"+{<}IS01{>}+"{>}"{>}{<}SX02,{<}PV02{>}{>}{<}IF{<}VA|02{>}>
0{>}{<}PR(Hit a key to continue...) 02=@02{>}{<}SX02,{<}RK{>}
{>}{<}GLa{>}{<}EI{>}{<}PRDone{>}{<}EX{>}[cr|lf][cr|lf]
-nd
XPLeNCODE
Of course, you could reach the same result with a more conventional
XS parse.
--
Carl Distefano
cld@xxxxxxxx