BASIC-SO

Functions

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

20INPUT "WHAT ARE THE NUMBERS TO DIVIDE";X,Y

30Z = X/Y

40PRINT "QUOTIENT IS";Z

50GOTO 20

60IF ERR <> 11 OR ERL <> 30 THEN 90

70PRINT "YOU CAN'THAVE A DIVISOR OF ZERO!"

80RESUME 20

90ON ERROR GOTO 0

100END

RUN

WHAT ARE THE NUMBERS TO DIVIDE? ?045,9

QUOTIENT IS 5

WHAT ARE THE NUMBERS TO DIVIDE? 11,0

? 11,0

YOU CAN'THAVE 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.

EXP(expression)

10INPUT A

20B = EXP(A)

30PRINT B

40END

RUN ?5 148.4131 OK

?

FIX

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

7-5

Page 69
Image 69
Intel 9800758-02 manual Fix, Ok·