The Val Function; The Str$ Function; The Square Root Function (Sqr); The Absolute Value Function (Abs) - Commodore 128D User Manual

Hide thumbs Also See for 128D:
Table of Contents

Advertisement

The STOP and
CONT (Continue)
Commands
The VAL
The VAL function returns a numeric value for a
Function
string argument. Clear the computer's memory
and type this program:
10A$ = "64"
20A = VAL(A$)
30 ? "THE VALUE OF";A$;"IS";A
40 END
The STR$
The STR$ function returns the string representa-
Functlon
tion of a numeric value. Clear the computer's
memory and type this program.
10A = 65
20A$ = STR$(A)
30 ? A" IS THE VALUE OF";A$
The Square Root Function (SQR)
The square root function is SQR. For example, to find the square root
of 50, type:
You can find the square root of any positive number in this way.
The Absolute Value Function (ABS)
The absolute value function (ABS) is very useful in dealing with nega
tive numbers. You can use this function to get the positive value of
any number—positive or negative. Try these examples:
? ABS(5)" IS EQUAL TO "ABS(- 5) \
You can make the computer stop a program, and resume running it
when you are ready. The STOP command must be included in the
program. You can put a STOP statement anywhere you want to in a
program. When the computer "breaks" from the program (that is,
stops running the program), you can use DIRECT mode commands
to find out exactly what is going on in the program. For example, you
can find the value of a loop counter or other variable. This is a power
ful device when you are "debugging" or fixing your program. Clear
the computer's memory and type the program below.
70
USING C128 MODE—Advanced BASIC Programming

Advertisement

Table of Contents
loading

Table of Contents