Download Print this page

Radio Shack TRS-80 Model II Reference Manual page 236

Disk operating system
Hide thumbs Also See for TRS-80 Model II:

Advertisement

Model II TRSDOS
PARSER
(function code 48)
This general-purpose routine "parses" (analyzes) a text buffer into fields and
subfields.
PARSER
is useful for analyzing
TRSDOS
command lines
including keyword commands, file specifications, keyword options and
parameters. It can also be used as a fundamental routine for a compiler or text
editor.
By necessity, the description of
PARSER
is rather long and detailed. In
actual use, the routine is as convenient as it is powerful. For example,
PARSER
is designed to allow repetitive calls for processing a text buffer; on
exit from the routine, parameters for the next call are all readily available in
appropriate registers.
The routine has pre-defined sets of field-characters and separators; you can
use these or re-define them to suit your application.
In general, a field is any string of alphanumeric characters (A-Z, a-z, 0-9) with
no embedded blanks. Fields are delimited by separators and terminators,
defined below. For example, the line:
BAUD=300, PARITY=EVEN WORD=7
contains 6 fields:
BAUD,
300,
PARITY, EVEN, WORD,
and
7.
However, a field can also be delimited by paired quote marks:
"field" or 'field'
When the quote marks are used,
any
characters, not just alphanumerics,
are taken as part of the field. The quote marks are not included in the field.
For example, the line:
'DATE(07/11/79)'
will be interpreted as one field containing everything inside the quotes. When
a quote mark is used to mark the start of a field, the same type of quote mark
must be used to mark the end of the field. This allows you to include quotes in
a field, for example:
"X'FFOO' "
will be parsed as one field containing everything inside the double quotes
"
", including the single quote marks'
A separator is any non-alphanumeric character.
PARSE
will always stop when
a separator is encountered,
except
when the separator is a blank
(X'20').
Leading and trailing blanks are ignored. After trailing blanks,
PARSE
stops at
the beginning of the next field, or on the first non-blank separator.
272

Advertisement

loading