Functions

BASIC·SO

SPC

The SPC function returns a string of spaces n characters long when used with a PRINT statement, as in the example below. SPC, unlike the SPACE$ function, does not return an actual string, only a series of spaces. It may only be used with a PRINT statement.

SPC (integer)

10 PRINT

20 PRINT SPC (10); "Question 1":PRINT:PRINT

30 PRINT SPC (15);"How many states are there in binary logic?":PRINT

40 INPUT A$:PRINT:PRINT

50 IF A$ = "2" THEN PRINT "Correct" ELSE GOTO 750

saR

The SQR function returns the square root of the specified expression. The expres- sion must evaluate to be greater than or equal to zero, or an error message is returned. SQR is calculated in single precision.

SQR(expression)

The program below finds the square root of input A, which is entered by the user, then displays it:

10 INPUT A

20PRINT SQR(A)

30END

RUN ? 45 6.70821 RUN ? -1

ILLEGAL FUNCTION CALL IN 20

STRINGS

The STRING$ function returns a string of the same character repeated the specified number of times. If an integer argument is used, the ASCII character having that numeric code is returned the specified number of times. If a string argument is sup- plied, the first character of the string is returned the specified number of times.

STRING$ (expression, expressionlstring expression)

10A$ = STRING$(10,97)

20PRINT A$ RUN aaaaaaaaaa

OK

10A$=STRING$(10,"A")

20PRINT A$ RUN AAAAAAAAAA Ok

7-12

Page 76
Image 76
Intel 9800758-02 manual Spc, SPC integer, If A$ = 2 then Print Correct Else Goto, SQRexpression