InputBegin InputParseInt InputParseDbl'End' I%<ref> InputAssignInt I% A(<ref> InputAssignDbl InputThe proposed translation is nearly identical except InputBegin now appears after all the InputParseType codes, which are now reversed, and an 'End' sub-code is no longer needed. At run-time, each InputParseType pushes a data type to an input stack. InputBegin starts by issuing the prompt, gets the input, and processes the input stack without popping the items. Each item on the input stack contains a data type and an input value, which is filled in as each value is successfully parsed. If an error is detected, the error is displayed and the character at which the error occurred is highlighted. At which point, the user is given the opportunity to edit the input and try again.
InputParseDbl InputParseInt InputBegin I%<ref> InputAssignInt I% A(<ref> InputAssignDbl Input
Upon successful input (all values parsed and saved on the input stack), execution proceeds to the next code. Each reference gets pushed to the evaluation stack and each InputAssignType pops the reference, pops a value from the input stack, and assigns the value to the reference.
There is not much left for Input to perform, but it does check for the 'Keep' sub-code (semicolon at the end of the statement to keep the cursor on the same line), and if not set, moves the cursor to the beginning of the next line.
For the INPUT PROMPT command, the beginning of the translation is varied slightly to allow for the prompt string expression. The beginning of the line contains the tokens for the string expression (before the first InputParseType). There is an InputBeginStr instead of InputBegin, which could have an optional 'Question' sub-code depending if the prompt expression was followed by a semicolon (no question) or comma (question). At run-time, this code will pop the result of the string expression from the evaluation stack, and proceeds the same as InputBegin except with the specified prompt.
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.)