LEX 'INCRL' * Another experiment with statements. Jack Elhay ID #EC * 28/8/88. PPPM. MSG 0 * INCR increments a variable POLL 0 * the default optional increment is 1 ENTRY INCR * decrementing is done by using negative increments CHAR #D * a statement, generally usable KEY 'INCR' * Syntax: INCR [,] TOKEN 129 * it is a good idea to initialise the variable ENDTXT FIXDC EQU #05493 * FIX decompile can be used VARP EQU #0350E * variable parse SYNTXe EQU #02E2B * parse syntax error exit NTOKEN EQU #0493B * output next token RESPTR EQU #03172 * reset pointers after parse FIXP EQU #02A6E * FIX parse = NUMCK followed by RESPTR EXPEXC EQU #0F186 * expression execute DEST EQU #0F7B0 * save variable destination information AD2-12 EQU #0C35F * add two 12-forms uRES12 EQU #0C994 * round 15-form in (A,B) to 12-form in C STORE EQU #0F5F8 * store into variable NXTSTM EQU #08A48 * return to main loop EOLXCK EQU #05405 * test byte in A(B) for one of the EOL's POP1R EQU #0E8FD * pop one real tCOMMA EQU #F1 * the comma token fixdc GOVLNG FIXDC * decompile INCRp GOSBVL VARP * parse for a variable GOC VAROK * if variable found, carry set GOVLNG SYNTXe * otherwise we have syntax error VAROK GOSBVL NTOKEN * output the next token LC(2) tCOMMA * load the comma token into C(B) ?A=B B * match? GOYES fixp * yes, we take care of the number with FIXP GOVLNG RESPTR * no, finish the parse fixp GOVLNG FIXP * finish for two parameters REL(5) fixdc REL(5) INCRp INCR GOSBVL (EXPEXC)-14 * this is EXPEX-, collapses mathstack to forstk GOSBVL DEST * save destination info GOSBVL EXPEXC * evaluate CD1EX * save D1 in C D1=(5) #2F98D * somewhere to store the variable's value DAT1=A W * value is in A(W), save it D1=C * restore D1 A=0 W * clean up A A=DAT0 B * read next byte in the token stream GOSBVL EOLXCK * check for End Of Line tokens(@,!,EOL) C=0 W * prepare for one parameter case P= 1 * sneaky way to make a 1 CPEX 14 * P=0 & C=0100000000000000 (one in BCD) R0=C * save it in R0 GOC ONEPAR * carry set if EOLXCK finds an EOL D0=D0+ 2 * otherwise, step over comma GOSBVL EXPEXC * evaluate 2nd parameter R0=A * save value in R0 D1=D1+ 16 * step past the optional parameter ONEPAR CD1EX * save D1 in C D1=(5) #2F98D * point D1 to the stored variable A=DAT1 W * read the variable's value D1=C * restore D1 C=R0 * copy the increment into C GOSBVL AD2-12 * add increment to var. value GOSBVL uRES12 * 15-form=>12-form in C A=C W * result must be in A(W) & DAT1=C W * on the stack GOSBVL STORE * store the result into the variable GOVLNG NXTSTM * exit to NeXTSTMent * A simple call to EXPEXC or EXPEX- will evaluate all the numbers in the * token stream, and put them all on the mathstack. It seems that if DEST * is called, one can forget parameters after the variable. They will have * to evaluated separately. * This contrasts with DELAY from the mainframe statements and my recent * effort in NEWID & NEWTOKS (q.v.). * EOLXCK compares the token in A(B) with the tokens which are used to * terminate statements in a line of BASIC, namely the tokens for @, for * ! or for EOL (F0). If one of these is found, execution returns with * carry set. This can be used to choose whether the 2nd parameter is there * to be evaluated and popped. * A possible application might be in summations, eg: * S=0 @ FOR I=1 TO N @ INCR S,X(N) @ NEXT I , or, perhaps * as a counter in the form INCR I, (eg., IF THEN INCR I ELSE INCR J) * So another lesson has been learned, through trial and (much) error. * Regards and Happy Programming, * Jack Elhay.