EasyManua.ls Logo

Commodore PET - DEVELOPING A PROGRAM; Multiple Statements on a Line

Commodore PET
447 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...
ABS
SOR
EXP
Arrays of
up
to eleven elements (subscripts 0 to
10
for a one-dimen-
sional array) may be used where needed
in
PET BASIC, just
as
variables can
be used
as
needed. Arrays containing more than eleven elements need to be
"declared"
in
a Dimension statement. Dimension statements are described
later in this chapter and in Chapter
4.
An
array (always
with
subscripts) and a
single variable of the same
na
me are treated
as
separate items by
PET
BASIC.
Once dimensioned.
an
array cannot
be
referenced
with
different dimensions.
FUNCTIONS
Another
element of
PET
BASIC
is
the built-in function. A function performs
a predefined operation
on
a specified data item
or
items; they are referred
to
as
"arguments."
For example. vou
will
use functions
to
find the square root of a
number.
to
convert a f10ating point number to integer form.
to
find the number of
characters in a string. or to set a tab
to
a certain
column
on
the display screen.
Functions are a great programming convenience.
We
will
summarize the functions supported by
PET
BASIC now
so
that
Vou
can get
an
overview of
what
functions are available
to
Vou
on
the
PET.
The func-
tions are described in detail in Chapter
4.
A function may opera
te
on
one
or
more constants, variables,
or
expres-
sions; these are termed the arguments of the function.
The argument
is
writ-
ten in parentheses
following
the function name:
fu
nction
(arg)
If a function requires
two
or more arguments. they are separated by commas:
fu
nction(arg1.arg2)
If the arguments of a
fu
nction (arg
1.
arg2. etc.) are expressions.
which
is
allowed by
PET
BASIC. then the expressions are evaluated. reducing each argu-
ment
to
a single number. before the
function
itself
is
evaluated.
When
a function appears in a BASIC statement. it
is
evaluated before any
other part of the BASIC statement.
The following functions constitute the arithmetic function group:
INT Converts a floating point argument
to
its integer equivalent.
SGN
Returns the sign of an argument: +1 for a positive argument.
-1
for a negative argument. 0 for a 0 argument.
Returns the absolute value of
an
argument. A positive argument
does not change: a negative argument
is
converted to its posi-
tive equivalent.
Computes the square root of the argument.
Raises the
naturallogarithm
base e to the power of the argument
(e
arg1
).
71

Table of Contents

Related product manuals