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

RE: programming question



Reply to note from Patricia M Godfrey  Sat, 6
Nov 2004 17:13:48 -0500

> Before you start numbering, issue the command DC 1=1;
> alternatively, you can embed the code ≪DC1=1≫. Then each time
> you want to enter an imcrementing number either type C1 on the
> command line

To judge from the subject header, Morris's question has to do with
programming technique, as opposed to manual text entry. In other
words, in XPL, how do you initialize a counter, then increment it
and insert (hard-code) the counter number in text at the desired
cursor position? Here's a basic schema, with gaps for (1) a
conditional test to prevent the counter from incrementing ad
infinitum (i.e., to avoid an endless loop), and (2) code to position
the cursor before writing the counter:

;*;       Initialize counter
;*;        Begin loop
;*; <=========== IF okay to continue...
+1>;*;   Increment counter
;*;        Write counter
;*;        Loop back
;*;       Else Exit

Here's a working example that writes five counters at the cursor
position. The IF test is, simply, is the counter less than 5? If
so, increment and continue; else EXit.

XPLeNCODE v2.0
b-gin [UNTITLED]
{<}SX01,0{>};*;[cr|lf]{<}LBa{>};*;[cr|lf]{<}IF{<}PV01{>}<5{>}
;*;[cr|lf]{<}SX01,{<}PV01{>}+1{>};*;[cr|lf]{<}SX01,{<}IS01{>}
{>};*;[cr|lf]{<}GT01{>};*;[cr|lf] [BX_]p[Q2_]{<}GLa{>};*;[cr|
lf]{<}EI{>}{<}PRDone{>}{<}EX{>}[cr|lf][cr|lf]
-nd
XPLeNCODE

--
Carl Distefano
cld@xxxxxxxx