| Routines

1DEC: THE 'READ' COMMAND ROUTINE

The READ command allows for the reading of a DATA list and has an effect similar to a series of LET statements. Each assignment within a single READ statement is dealt with in turn. The system variable X-PTR is used as a storage location for the pointer to the READ statement whilst CH-ADD is used to step along the DATA list.
READ_3 | 1DEC | RST $20 | Come here on each pass, after the first, to move along the READ statement.
The address of this entry point is found in the parameter table.
READ | 1DED | CALL CLASS_01 | Consider whether the variable has been used before; find the existing entry if it has.
| 1DF0 | CALL SYNTAX_Z | Jump forward if checking syntax.
| 1DF3 | JR Z,READ_2
| 1DF5 | RST $18 | Save the current pointer CH-ADD in X-PTR.
| 1DF6 | LD ($5C5F),HL
| 1DF9 | LD HL,($5C57) | Fetch the current DATA list pointer (DATADD) and jump forward unless a new DATA statement has to be found.
| 1DFC | LD A,(HL)
| 1DFD | CP ","
| 1DFF | JR Z,READ_1
| 1E01 | LD E,$E4 | The search is for 'DATA'.
| 1E03 | CALL LOOK_PROG | Jump forward if the search is successful.
| 1E06 | JR NC,READ_1
Report E - Out of DATA.
| 1E08 | RST $08 | Call the error handling routine.
| 1E09 | DEFB $0D
Continue - picking up a value from the DATA list.
READ_1 | 1E0A | CALL TEMP_PTR1 | Advance the pointer along the DATA list and set CH-ADD.
| 1E0D | CALL VAL_FET_1 | Fetch the value and assign it to the variable.
| 1E10 | RST $18 | Fetch the current value of CH-ADD and store it in DATADD.
| 1E11 | LD ($5C57),HL
| 1E14 | LD HL,($5C5F) | Fetch the pointer to the READ statement from X-PTR and clear it.
| 1E17 | LD (IY+$26),$00
| 1E1B | CALL TEMP_PTR2 | Make CH-ADD once again point to the READ statement.
READ_2 | 1E1E | RST $18 | Get the present character and see if it is a ','.
| 1E1F | CP ","
| 1E21 | JR Z,READ_3 | If it is then jump back as there are further items; otherwise return via either CHECK_END (if checking syntax) or the 'RET' instruction (to STMT_RET).
| 1E23 | CALL CHECK_END
| 1E26 | RET