APPENDIX C

INTRINSIC FUNCTIONS


Standard BASIC provides several commonly used algebraic and string functions which may be called from any program without further definition. In the following list, X arid Y stand for any numerical expressions, I and J stand for integers (or expressions whose values are always integers), and X$ and Y$ stand for string expressions.

Function        Call Format
ABS             ABS(X)

Returns absolute value of expression X. ABS(X)=X if X>0, 0 if X is 0 and -X if X<O.

ASC             ASC(X$)

Returns the ASCII number of the first character of the string X$ (you may use a string variable or a string). ASCII numbers are listed in Appendix G.

ATN             ATN(X)

Returns the arctangent (inverse hyperbolic tangent) of X. The result is in radians in the range -pi/2 to pi/2.

CHR$            CHR$(I)

Returns the character with ASCII code I. Either a string of one element or a control function. ASCII codes are in Appendix G.

COS             COS(X)

The cosine function: returns cos(X). X must be in radians.

EXP             EXP(X)

Returns e to the power X. X must be <=87.3365.

FRE             FRE(0)

Returns number of bytes in memory not being used by Standard BASIC. If argument is a string, returns number of free bytes in string space. Use this statement to look at it: PRINT FRE(0) or PRINT FRE(X$).

INP             INP(I)

Reads a byte from port I.

INT             INT(X)

Returns the largest integer <=X.

LEFT$           LEFT$(X$,I)

Returns leftmost I characters of string X$.

LEN             LEN(X$)

Returns length of string X$. Non-printing characters and blanks are counted.

LOG             LOG(X)

Returns natural log of X; X>O.

MID$            MID$(X$,I|,J|)

Without J, returns rightmost characters from X$ beginning with the Ith character. If I>LEN(X$), MID$ returns the null string (that is, one with no characters). 0<I< 255. With 3 arguments, returns a string of length J of characters from X$ beginning with the Ith character. If J is greater than the number of characters in X$ to the right of I, MID$ returns the rest of the string. 0<=J<=255.

RND             RND(X)

Returns a random number between 0 and 1. X<0 always produces one particular number. X>0 gives a new number each time. X=0 gives the last number returned.

PEEK            PEEK(l)

Returns the byte, in the range 0 to 255, in location I (decimal), where I<32768.

POS             POS(I)

Returns present column position of terminal's print head. Leftmost position=0.

RIGHT$          RIGHT$(X$,I)

Returns rightmost I characters of string X$. If I>=LEN(X$), returns X$.

SGN             SGN(X)

Returns the sign of X. If X>0 returns 1, if X=0 returns 0, if X<0 returns -1.

SIN             SIN(X)

Returns the sine of the value of X in radians. (COS (X)=SIN(X+pi/2).)

SPC             SPC(I)

Prints I blanks on the terminal, 0<=I<=255. You must not leave a space between SPC and the parenthesis (or the Sorcerer will think that SPC is a variable, because the reserved word is SPC(.)

SQR             SQR(X)

Returns square root of X. X must be >=0.

STR$            STR$(X)

Returns string representation of value of X.

TAB             TAB(I)

Spaces to position I on the terminal. Space 0 is the leftmost space, 63 the rightmost. If the carriage is already beyond space I, TAB has no effect. (Use SPC to make a relative move.) May only be used in PRINT statements. Just as with SPC, make sure to leave no space between TAB and the parenthesis, or the Sorcerer will think TAB is a variable, because the reserved word is TAB(.

TAN             TAN(X)

Returns tangent (X). X must be in radians.

USR             USR(X)

Calls the user's machine language subroutine with argument X. See Chapter 12, THE USR FUNCTION.

VAL             VAL(X$)

Returns numerical value of string X$. If first character of X$ is not +, -, or a digit, VAL(X$)=0.


Table of Contents | Prev | Next

The Trailing Edge