Sunday, June 20, 2010

Translation – INPUT command

Without going the entire process in how the translation was arrived at, here is the general form of the translated INPUT statement (optional items in square brackets, repeating items in braces):
[<expr>] InputGet {<variable> InputType}... Input
The InputGet code will output an optional prompt string (evaluated by the preceding string expression and pushed to the evaluation stack) and the “? ” if selected, and then will get the input. The InputType codes will parse the input for a appropriate data type. Any errors cause a loop back to the InputGet code (where the prompt is issued again). When there are no errors, the Input code will assign the values to the variables, pop the prompt string from the evaluation stack, delete the string if it is a temporary, and advancing the cursor to a next line if not suppressed by a trailing semicolon.

The InputGet code will use sub-code flags to indicate whether there is a prompt string to output and whether to output the “? ” string. The Input code will use sub-code flags to indicate if there is a temporary prompt string that needs deleted and whether the cursor should be kept on the same line.

Normally sub-code flags are only used by the Recreator when generating the original source, and ignored during run-time (so as not to waste execution time checking them). But, considering that this is the INPUT command, a command that is about to stop and wait for an extremely slow user, using time to check sub-code flags is not going to have any significant impact. Next, a more detailed look at how the INPUT command will be executed...

No comments:

Post a Comment

All comments and feedback welcomed, whether positive or negative.
(Anonymous comments are allowed, but comments with URL links or unrelated comments will be removed.)