I recently noticed parse$. It allows executing data -- in this case a string -- that you may have previously manipulated. Certain other basics do this as does lisp, mumps, etc. This has some interesting uses. For one, given Chuck's excellent graphing routines, it is trivial to write a routine to plot a graph of any function of a single variable expressible in basic. See attached short program graph.bas.

Another routine -- parsetest.bas -- is attached. You can use it to evaluate expressions that it prompts for. Suppose you are unsure of how some function or operator works (example: how are % and mod different). Without an interactive option in Basic, you would have to write a little test program and save it and run it (and if you made a mistake more than once). You can run parsetest in place of many test programs.

Built into parsetest are also some utility functions to demonstrate how you can write complete programs in strings that you parse. To function properly in these expressions you need value returning functions. Included are the functions set (to set numeric variables), sets (to set string variables), puts (to output a string), and when (which repeatedly parses an expression while it returns true). You can implement multiple program steps by concatenating function invocations with "+" (or "-" or "*"). Try "demo1()" and "demo2()" at the parsetest prompt. There is also a function -- factor(n) -- that shows how to implement recursive routines without blowing the stack. None of this is intended to be useful except to demonstrate the power of parse$.

Another routine -- parsetest.bas -- is attached. You can use it to evaluate expressions that it prompts for. Suppose you are unsure of how some function or operator works (example: how are % and mod different). Without an interactive option in Basic, you would have to write a little test program and save it and run it (and if you made a mistake more than once). You can run parsetest in place of many test programs.

Built into parsetest are also some utility functions to demonstrate how you can write complete programs in strings that you parse. To function properly in these expressions you need value returning functions. Included are the functions set (to set numeric variables), sets (to set string variables), puts (to output a string), and when (which repeatedly parses an expression while it returns true). You can implement multiple program steps by concatenating function invocations with "+" (or "-" or "*"). Try "demo1()" and "demo2()" at the parsetest prompt. There is also a function -- factor(n) -- that shows how to implement recursive routines without blowing the stack. None of this is intended to be useful except to demonstrate the power of parse$.