Chapter
11
1
Technical
Information
Accessing String Variables
If the parameter passed in
a
CALL statement is
a
string expres-
sion, the parameters offset points to the
string descriptor.
If the
argument passed in
a
USR function call is a string expression,
the
DX
register points
to
the
string descriptor.
The
string descriptor
is a 3-byte area
of
memory that points to
the text
of
the string. The
string descriptor
contains the
following:
Byte 0 contains the length
of
the string (0 to 255).
Byte
1
contains the lower
8
bits
of
the string
starting address in BASIC’s data segment.
Byte 2 contains the upper
8
bits
of
the string
starting address in BASIC’s data segment.
The text of the string may be altered by the subroutine, but the
length
of
the string
must not
be changed. BASIC cannot
cor-
rectly manipulate strings if their lengths are modified by exter-
nal routines.
Since the
string descriptor
points
to
an area
of
memory in your
BASIC program, you must be careful not to alter
or
destroy your
program. To avoid unpredictable results, add the concatenation
symbol
(+)
to the string. This forces the string
to
be copied into
string space, where the string may be modified without affecting
the program.
Example
20 A$
=
“MONTHLY SALES REPORT”
+
“
”
File Control Block
A
file control block is
a
storage area in BASIC’s data segment
that contains information BASIC needs
for
all functions per-
formed on that file. When you execute the VARPTR function and
specify the buffer number, BASIC returns the address
of
the
BASIC file control block
for
that file. Note that this is the BASIC
file control block, not the
DOS
file control block. The address is
specified
as
an offset into BASIC data segment. In this section
we define the information in the file control block. Offsets are
relative
to
the value returned by VARPTR. Length is in bytes.
358