EasyManua.ls Logo

Radio Shack TRS-80 Model III - Page 132

Radio Shack TRS-80 Model III
274 pages
Print Icon
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 by
commas.
If the 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
AS,
starting
with the third
character,
with
a length of
2.
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
.
For example
A
=
SQR
(7)
Assigns
A
the
data returned
as the
square root
of 7
.
PRINT
MID$(A$,3,2)
Prints the
substring
of
AS starting at the
third character
and 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.
122

Other manuals for Radio Shack TRS-80 Model III

Related product manuals