- Print the prompt string is present
- Print the “? ” prompt (if selected)
- Get the input
- Parse a value from the input for the data type of the variable
- Save the value and repeat for each variable
- If there is an error with a value or to many or too little values
- Then print “Redo from start” and go back to the first step
- Assign each variable to its corresponding value
- Move the cursor to the next line (unless there was a semicolon at the end)
Like with the PRINT statement, there will be separate codes for parsing the input for a particular data type - InputDbl, InputInt, and InputStr (step 3). The values can't be assigned until all the values have been parsed and are valid, so the values need to be saved. Pushing them onto the evaluation stack right after the variable's reference is the logically thing to do.
Once all the values are input, the values can be assigned to the variables (step 8). The run-time code for the Assign data type can be used since the values will be on the stack (variable reference first and then data value). If there no semicolon at the, the cursor needs to be advanced to the next line. The run-time code for Print can be used (step 9).
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.)