EasyManua.ls Logo

Radio Shack TRS-80 Model 3 - Page 132

Radio Shack TRS-80 Model 3
276 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
TRS-80 MODEL III
Functions
A function is a built-in sequence
of
operations which BASIC will perform on data.
A function is actually a subroutine which usually returns a data item.
BASIC
functions save you from having to write a BASIC routine, and they operate faster
than a
BASIC routine would.
A function consists
of
a keyword which is usually followed by the data that you
specify. This data is always enclosed in parentheses;
if
more than one data item is
required, the items are separated bycommas.
Ifthe data required is
termed'
'number" you may insert any numerical expression.
If
it is termed" string" you may insert a string expression.
Examples:
SQR(A +
6)
Tells BASIC to compute the square root
of
(A
+ 6).
MID$ (A$, 3,2)
Tells BASIC to return a substring
of
the string
A$,
starting with the third character,
with a length
of2.
Functions cannot stand alone in a BASIC program. Instead they are used in the
same way you use expressions- as the data in a statement.
Forexample
A = SQR(7)
Assigns A the datareturned as the square root
of
7.
PRINT MID$ (A$,
3,
2)
Prints the substring
of
A$ starting at the third characterand two characters long.
If
the function returns numeric data, it is a numeric function and may be used in a
numeric expression.
If
it returns string data, it
is
a string function and may be
used in a string expression.
1/28

Related product manuals