Functions can be used in any expression, in BASIC programs or at the prompt (eg, PRINT SQR(2)). Functions whose names end with $ return strings; all others return numbers.
You can also define your own functions with DEF.
The trigonometric functions use radians, and all floating-point calculations use 64-bit (double-precision) values, with about 15 significant digits. If floating-point support is disabled (see Starting BASIC-DOS), numeric variables default to integers, and / and ^ are integer operations.
ABS(x)
Returns the absolute value of x.
ATN(x)
Returns the arctangent of x, in radians (eg, 4*ATN(1) is pi).
COS(x)
Returns the cosine of x, where x is in radians.
EXP(x)
Returns e (2.71828…) raised to the power of x.
FIX(x)
Returns x truncated to an integer (eg, FIX(-2.5) is -2). See also INT.
INT(x)
Returns the largest integer less than or equal to x (eg, INT(-2.5) is -3). See also FIX.
LOG(x)
Returns the natural logarithm of x, which must be greater than zero.
RND[(n)]
Returns a random number from 0 up to (but not including) 1. n has the same effect as with RND%.
RND%[(n)]
Returns a random integer between 0 and MAXINT, inclusive. If n is negative, the generator is reseeded first, and if n is zero, the previous random integer is returned.
SIN(x)
Returns the sine of x, where x is in radians.
SQR(x)
Returns the square root of x, which must not be negative.
TAN(x)
Returns the tangent of x, where x is in radians.
Strings can contain up to 255 characters. Character positions start at 1.
ASC(string)
Returns the character code (0-255) of the first character of string (or 0 if string is empty).
CHR$(code)
Returns a one-character string containing the character with the specified code (0-255).
HEX$(n)
Returns the hexadecimal representation of the integer n. Negative values are treated as unsigned 32-bit values (eg, HEX$(-1) is “FFFFFFFF”).
INSTR([start,]string1,string2)
Returns the position of string2 within string1, searching from position start (default 1), or 0 if not found.
LCASE$(string)
Returns string with all upper-case letters converted to lower-case.
LEFT$(string,n)
Returns the leftmost n characters of string.
LEN(string)
Returns the number of characters in string (0-255).
MID$(string,start[,n])
Returns n characters of string, beginning at position start (or the rest of string if n is omitted). The MID$ statement (eg, MID$(A$,2) = "X") isn’t supported yet.
OCT$(n)
Returns the octal representation of the integer n.
RIGHT$(string,n)
Returns the rightmost n characters of string.
SPACE$(n)
Returns a string of n spaces.
STR$(x)
Returns x as a string, with a leading space if x is not negative.
STRING$(n,char)
Returns a string of n copies of char, which can be either a character code or a string (whose first character is used).
UCASE$(string)
Returns string with all lower-case letters converted to upper-case.
VAL(string)
Returns the numeric value of string, ignoring any blanks. If string does not begin with a number, the result is 0. The &H and &O prefixes aren’t supported yet.
DATE$
Returns the current date as a string in the form MM-DD-YYYY.
ERR
Returns the number of the last error (see ON ERROR).
FRE(x)
Compacts string memory and returns the number of bytes available. The argument is ignored.
INKEY$
Returns the next key pressed, without waiting (an empty string if no key was pressed). Extended keys (eg, cursor keys) return two characters: a null and the key’s scan code.
10 LET K$ = INKEY$:IF K$ = "" THEN GOTO 10
PRINT "You pressed "; K$
PEEK(offset)
Returns the byte at offset in the segment set by DEF SEG. For example, this returns the low byte of the BIOS timer tick count:
DEF SEG=0:PRINT PEEK(&H46C)
TIME$
Returns the current time as a string in the form HH:MM:SS.
Equal to the return code from the last program executed (eg, IF ERRORLEVEL = 1 THEN PRINT "Failed").
Equal to the largest positive integer (2147483647).
Copyright (c) 2020-2026 Jeff Parsons Released under MIT License