EQN, Flag 10 and Comments (AND Diagnostics!) in 33s Programs Message #8 Posted by Paul Brogger on 2 Mar 2004, 1:00 p.m., in response to message #5 by Wayne Stephens
I've always thought the fundamental capability of most any programming language is the ability to include comments in the code. [That way, at the very least, if the language's developers don't get 'round to doing anything else, it can still be used for pseudo code! ;^) ]
With the memory limitations on early RPN programmables, I guess it made sense that no explicit commenting feature was generally made available.
As hinted to in several recent posts, however, with the 33s, real comments become possible.
By following a conditional test with an equation, one may avoid ever having the equation evaluated simply by insuring the conditional test always evaluates false. (Remember "do if true"?) And, the 32sII/33s lets you insert just about anything into a program while in "EQN" mode.
So, one might begin a dot product subroutine with something like:
D0001 LBL D
D0002 CLx
D0003 X<>0?
D0004 DOT PRODUCT
...
Using Flag 10, some refinement is possible. The default setting of Flag 10 is "clear", which causes equations to be evaluated and put on the stack. Setting Flag 10 to "set" causes equations to be displayed (rather than evaluated) during program execution.
So, the simpler
D0001 LBL D
D0002 FS? 10
D0003 DOT PRODUCT
...
skips the comments with Flag 10 clear, and displays the comments as encountered when Flag 10 is set. Pretty cool!
Of course a drawback to setting Flag 10 is that (apparently) NO equations are evaluated -- even the ones you wanted to be. For flow-testing complex programs with legitimate equations included, one might supply a substitute value via a constant with:
D0032 SQRT(SQ(A)+SQ(B)+SQ(C))
D0033 FS? 10
D0034 1.23
...
It would appear that at least some of that "excess" 33s memory may have its uses after all, eh?
Edited: 2 Mar 2004, 4:06 p.m.
|