Initialize to read a string
|6502||On entry:||On exit:|
|Z||undefined|| NE = String is non-empty or quoted|
EQ = String is empty and unquoted
|Cy|| CC = Space or CR terminates unquoted string
CS = CR terminates unquoted string
|A||undefined||First character of string; =&0D if string empty and unquoted|
|Y||Offset of first character to scan||Offset of first character of string|
|(&F2),Y||Points to start of string||(&F2) preserved, Y updated|
Prepares GSREAD to read a string from a character array. The string may be enclosed in double quotes (") in which case spaces in the string are preserved. The string may also contain control codes and high-order characters encoded with an escape sequence.
GSINIT starts at the position given by (&F2),Y and scans forward, incrementing Y until a character other than space or CR is found.
If the string begins with " then &22 is returned in A and (&F2),Y points to the character after the ". In this case the Carry flag input to GSINIT has no effect, GSREAD will return characters until the closing " is reached. A CR encountered before the closing " causes error &FD, Bad string.
Otherwise (&F2),Y points to the first non-space character, which is returned in A. The Zero flag returns EQ if this is CR, indicating an empty, unquoted string. GSREAD will return characters until CR is reached, or also space if GSINIT was called with Carry Clear.
While processing a command line, the Zero flag set to NE on exit from GSINIT indicates that an argument is present. When the first call to GSREAD returns Carry Set, the flag from GSINIT distinguishes between an empty argument and no argument.
It is safe to call GSREAD at least once following GSINIT. However, after GSREAD returns Carry Set it must not be called again without an intervening GSINIT; otherwise, overshooting a closing " and reaching CR also raises a Bad string error.
The character returned by GSINIT is not necessarily the character returned by the first call to GSREAD.
- 6502 Entry Address: &FFC2 (I/O processor only)