BASIC-SO
The following program asks for a divisor
and
a dividend, and uses the error-
trapping routine in lines
60-90 to prevent division by zero (which has code 11) from
stopping the execution:
10
ON ERROR GOTO
60
20
INPUT
"WHAT
ARE THE NUMBERS TO DIVIDE";X,Y
30
Z =
X/Y
40
PRINT
"QUOTIENT
IS";Z
50
GOTO
20
60
IF ERR
<>
11
OR ERL
<>
30
THEN
90
70
PRINT
"YOU
CAN'T
HAVE A DIVISOR OF ZERO!"
80
RESUME
20
90
ON ERROR GOTO 0
100
END
RUN
WHAT
ARE THE NUMBERS TO DIVIDE?
?045,9
QUOTIENT
IS
5
WHAT
ARE THE NUMBERS TO DIVIDE? 11,0
? 11,0
YOU
CAN'T
HAVE A DIVISOR OF ZERO!
WHAT
ARE THE NUMBERS TO DIVIDE?
?
EXP
The function
EXP
returns the result
of
raising e (2.71828) to the specified power.
The specified value must be less than 88.7,
or
overflow occurs. The calculation
is
performed in single precision.
FIX
EXP(expression)
10
INPUT A
20
B = EXP(A)
30
PRINT B
40
END
RUN
?5
148.4131
OK
?
The FIX function truncates numbers with decimal fractions to their integer value.
FIX
(number)
PRINT FIX (41.99999)
41
Ok·
FRE
The
FRE
function returns the number
of
bytes
of
memory left when the dummy
argument (X)
is
given.
If
you give a string variable as a dummy argument (X$),
FRE
returns the number
of
free bytes in string storage space.
FRE (X)I(X$)
PRINT
FRE(X)
22490
Ok
Functions
7-5