Functions
7-14
Only integers can be used as arguments; other variables must
be
passed by reference.
This
is
done with the V
ARPTR
function, which returns the address
of
the specified
variable.
USR[$I#l%
I!][n]
[(parameter
... )]
Here
is
an
example of how the USRn statement
is
used:
10
CLEAR 1000, ODFFFH
20
DEFUSR4 =
OEOOOH
30
A$
=
"A
STRING"
40
A =
1E4
50
A# = 14D-3
60
AO/o
=
12
70
B = USR ! 4 (VARPTR(A!),VARPTR(K1),VARPTR(R#),VARPTR(LA%»
Arguments are returned in a similar fashion, unless the type character
is
omitted, in
which case registers
Hand
L are used.
Appendix E gives details
of
loading and running ASM-80,
PL/M-80,
and
FORTRAN-80 subroutines that may be called with USRn.
VAL
The VAL function returns the numerical value
of
string X$.
If
the string does not
represent a valid number,
V AL(X$) equals
O.
VAL
(string
expression)
10
INPUT A$
20
IF VAL(A$) = 0 THEN
60
30
A1
= VAL(A$) *
52
40
PRINT A1,
A$
50
END
60
PRINT
"ENTER
NUMERIC
DATA
ONLY."
70
GOT010
RUN
?4
208
4
VARPTR
The V
ARPTR
function returns the address in memory of a variable
or
the in-
put/
output buffer associated with a file number.
If
the variable has not yet been
assigned a value, an ILLEGAL
FUNCTION CALL error results. The main use
of
V
ARPTR
is
to pass variable or array addresses to assembly-language subroutines.
Arrays are passed
by
specifying V
ARPTR
(A
(0»
(or V ARPTR
(A(l»
if
OPTION
BASE 1
is
in effect)
so
that
the lowest addressed element
of
the array
is
returned. All
simple variables should be assigned values in a program before calling
V
ARPTR
for
any array; otherwise, allocation
of
a new simple variable
will
cause the addresses
of
all arrays to change. See Appendix E for further information about using V ARPTR.
VARPTR
(variablel#file
number)
BASIC-80