:toc:
Syntax:
ABS "(" a ")"
obtain the absolute value of a
Syntax:
ACOS "(" a ")"
obtain the arccosine of a
Syntax:
expr1 AND expr2
logical conjunction of expr1 and expr2
Syntax:
ALLOCATE "(" size [ "," flags ] ")"
Try to allocate size
number of bytes of memory, return pointer to allocated memory block if ok, NULL otherwise.
flags
is a combination of
* 0 MEMF_ANY
* 1 MEMF_PUBLIC
* 2 MEMF_CHIP
* 4 MEMF_FAST
* 256 MEMF_LOCAL
* 512 MEMF_24BITDMA
* 1024 MEMF_KICK
* 65536 MEMF_CLEAR
Syntax:
ASC "(" expr ")"
return the ascii code of the first character in the given string
Syntax:
ASSERT expr
raise an error message including line number information if the given expression evaluates to FALSE.
Syntax:
ASIN "(" a ")"
obtain the arcsine of the floating point number
Syntax:
ATN "(" a ")"
obtain the arctangent of the floating point number
Syntax:
BASE "." [ ident | CONSTRUCTOR ]
get a reference to the base class of the current class. Used to access methods and fields of the base class that could be hidden otherwise.
Can also be used to call the base classe's constructor.
Example:
CONSTRUCTOR myc2 (BYVAL iv1 AS INTEGER, BYVAL iv2 AS INTEGER)
BASE.CONSTRUCTOR(iv1)
END CONSTRUCTOR
Syntax:
BIN$ "(" expr ")"
return a string representation of the binary value of a given numeric expression
Syntax:
BREAK
insert a debug breakpoint here
Syntax:
CALL ( subCall | expDesignator )
call a SUB or FUNCTION.
Syntax:
CAST "(" typedesc "," expr ")"
casts an expression to a different data type
Syntax:
CHR$ "(" expr ")"
returns a string containing the single character associated with the given character code
Syntax:
CINT "(" x ")"
convert x to an integer by rounding the fractional portion.
NOTE: When the fractional portion is exactly .5, CINT always rounds up.
Syntax:
CLEAR [ "," "," stack ]
Resets global and static variables to their initializer values. Also resets dynamic arrays to contain all zeros.
NOTE: Will not reset local variables or global variables that do not have constant initializers. Will also not reset static arrays, UDTs nor objects.
If stack is specified the program will reserve and switch to a custom stack of the specified size on startup.
NOTE: Stack size can be set only once and will be in effect for the whole program run, no matter where the corresponding CLEAR statement appears in the program.
Example:
CLEAR ,,8192 : REM allocate custom stack of 8192 bytes
Syntax:
CLNG "(" x ")"
convert x to a long integer by rounding the fractional portion.
NOTE: When the fractional portion is exactly .5, CLNG always rounds up.
Syntax:
CLS
Clear the current output window and set the cursor position to the upper left corner
Syntax A:
[ PUBLIC | PRIVATE ] CONST id1 [AS type] "=" expr [ "," id2 [AS type] "=" expr [ "," ...]]
Syntax B:
[ PUBLIC | PRIVATE ] CONST AS type id1 "=" expr [ "," id2 "=" expr [ "," ...]]
declare constants
Syntax:
CONTINUE [ ( DO | FOR | WHILE ) ]
continue next iteration of a loop
Syntax:
COS "(" a ")"
obtain the cosine of the floating point number
Syntax:
DATA literal ( "," literal )*
add values to the data section of the program. Those values can be later READ by the program at runtime.
Syntax:
DATE$
return a string representation of the current date.
Date format used is mm-dd-yyyy
Syntax:
DEALLOCATE ptr
free memory that was allocated at ptr
Syntax:
[ PRIVATE | PUBLIC ] DECLARE procHeader [ LIB exprOffset identLibBase "(" [ ident ( "," ident)* ] ")"
Forward declare a SUB or FUNCTION. When the LIB portion of this command is used, an OS library function is declared.
Syntax:
[ PRIVATE | PUBLIC ] DECLARE PROPERTY ident [ parameterList ] [ AS typeDesc ]
Forward declare PROPERTY setter or getter in a UDT.
Example:
TYPE myc1
' ...
DECLARE PROPERTY p1 AS INTEGER : REM getter
DECLARE PROPERTY p1 (BYVAL f AS INTEGER) : REM setter
END TYPE
Syntax:
DEFINT letter [ "-" letter ] ( "," letter [ "-" letter ] )*
define all variables with names starting with the specified letter (or letter range) as INTEGER
Syntax:
DEFLNG letter [ "-" letter ] ( "," letter [ "-" letter ] )*
define all variables with names starting with the specified letter (or letter range) as LONG
Syntax:
DEFSNG letter [ "-" letter ] ( "," letter [ "-" letter ] )*
define all variables with names starting with the specified letter (or letter range) as SINGLE
Syntax:
DEFSTR letter [ "-" letter ] ( "," letter [ "-" letter ] )*
define all variables with names starting with the specified letter (or letter range) as STRING
Syntax A:
[ PUBLIC | PRIVATE ] DIM [ SHARED ] var1 [ "(" arrayDimensions ")" ] AS type [ "=" expr ] [ "," var2 ...]
Syntax B:
[ PUBLIC | PRIVATE ] DIM [ SHARED ] AS type var1 [ "(" arrayDimensions ")" ] [ "=" expr ] [ "," var2 ... ]
declare variables
Examples:
DIM f AS SINGLE : REM traditional QBasic Syntax
DIM SHARED g AS UBYTE : REM shared variable
DIM AS ULONG l1, l2 : REM declare multiple variables of the same type
DIM AS INTEGER a (9, 1) : REM 2D dynamic array
DIM AS INTEGER b (STATIC 9, 1) : REM 2D static, C-like array
DIM p AS INTEGER PTR : REM pointer
DIM fp AS FUNCTION (INTEGER) AS INTEGER : REM function pointer
static arrays are much faster than dynamic arrays but offer no runtime bounds checking
Syntax A:
DO [ ( UNTIL | WHILE ) expression ]
<code>
LOOP
Syntax B:
DO
<code>
LOOP [ ( UNTIL | WHILE ) expression ]
generic loop, loops until or while the given expression evaluates to TRUE. Expression test can either happen at the beginning or end of loop depending on the syntax used. If no UNTIL/WHILE clause is given, this will create an endless loop (which can still be exited from within the loop body using the EXIT statement).
Syntax:
END
exit the program (same as SYSTEM)
Syntax:
EOF "(" fileNo ")"
return TRUE if end of file is reached for input stream #fileNo, FALSE otherwise.
Syntax:
expr1 EQV expr2
logic equivalence of expr1 and expr2
Syntax:
ERASE arrayName [ "," arrayName2 ...]
Free the allocated memory for each dynamic array listed.
Syntax:
ERR : REM public variable
public variable that contains the last error number.
Syntax:
ERROR n
raise error code n, exits the program unless a corresponding handler is registered using the ON ERROR ... statement. ERR is set to the error number specified when calling the error handler.
Syntax:
EXIT ( SUB | FUNCTION | DO | FOR | WHILE | SELECT ) [ "," ( SUB | ... ) ... ]
exits a DO, WHILE or FOR loop, a FUNCTION or a SUB procedure, or a SELECT statement.
Syntax:
EXP "(" a ")"
obtain the exponential of the floating point number
Syntax:
TYPE ident1 EXTENDS ident2
OOP: declare class ident1 as child of class ident2
Syntax:
FIX "(" x ")"
return the truncated integer portion of x
Syntax:
FOR id [ AS type ] "=" expr TO expr [ STEP expr ]
<code>
NEXT [ id1 [ "," id2 [ "," ...] ] ]
counter loop using specified start and stop numerical boundaries, default increment is 1
Syntax:
FRE "(" x ")"
return the amount of free memory
* -2: stack size
* -1: chip + fast mem
* 0: chip mem
* 1: fast mem
* 2: largest chip mem
* 3: largest fast mem
Syntax:
GOTO ( num | ident )
jump a line label or a line number in the program
Syntax:
GOSUB ( num | ident )
jump to a subroutine at line label or a line number in the program
Syntax:
HEX$ "(" expr ")"
return a string representation of the hexadecimal value of a given numeric expression
Syntax A:
IF expr ( GOTO ( numLiteral | ident ) [ ( ELSE numLiteral | Statement* ) ]
| THEN ( numLiteral | Statement*) [ ( ELSE numLiteral | Statement* ) ]
)
Syntax B:
IF expr THEN
<code>
( ELSEIF expr THEN
<code> )*
[ ELSE
<code> ]
( END IF | ENDIF )
executes a statement or statement block depending on specified conditions.
Syntax:
IMPORT id
import a module
Syntax:
INPUT [ ";" ] [ prompt (";" | ",") ] expDesignator ( "," expDesignator* )
read input from the keyboard, store values in the variables given.
Syntax:
INPUT "#" expFNo "," expDesignator ( "," expDesignator* )
read input from file stream, store values in the variables given.
Syntax:
INSTR "(" [n] "," x "," y ")"
look for the first occurrence of string y in string x and return the (1-based) character position, if found, 0 otherwise. If n is specified, the search will start at the nth character of x, otherwise search will start at the beginning.
Syntax:
INT "(" x ")"
return the largest integer less than or equal to x
Syntax:
LBOUND "(" array [ "," dimension ] ")"
Return the lower bound for the given array dimension.
Syntax:
LCASE$ "(" s ")"
return an all-lowercase version of s
Syntax:
LEFT$ "(" s "," n)
returns the leftmost n characters in s
Syntax:
LEN "(" s ")"
return the length of string s in characters.
Syntax:
LET expDesignator "=" expression
assign the value of an expression to a variable or designator. The LET keyword is optional.
Syntax:
LINE INPUT [ ";" ] [ stringLiteral ";" ] expDesignator
request a STRING keyboard entry from a program user
Syntax:
LINE INPUT "#" expFNo "," expDesignator
request a STRING input from file stream
Syntax:
LOCATE [ row ] [ "," col ]
move cursor to col / row
Syntax:
LOG "(" l ")"
obtain the natural logarithm of the floating point number
see DO...LOOP
Syntax:
_MEMSET "(" dst "," c "," n ")"
set n bytes of memory to c starting from dst
Syntax:
MID$ "(" s "," n ["," m] ")"
Return portion of string s beginning at character position n (1 based) and length m. When m is not specified, the function returns the remainder of the string from the starting character position. If m reaches beyond the string end it will be trimmed automatically.
Example:
DIM AS STRING s, s1, s2, s3
s = "SundayMondayTuesday"
s1 = MID$(s, 7, 6)
ASSERT s1="Monday"
Syntax:
expr1 MOD expr2
modulus operation on expr1 and expr2.
Syntax:
NEW ident [ "(" actualArgs ")" ]
dynamically allocate a new object of class ident passing the given arguments to its constructor, if any.
Example:
DIM AS ExecList PTR choices = NEW ExecList(NT_USER)
choices->AddTail(NEW ExecNode(,,"First"))
see FOR
Syntax:
NOT expr
return logical not of expr
Syntax:
OCT$ "(" expr ")"
return a string representation of the octal value of a given numeric expression
Syntax:
ON ERROR CALL handler
call SUB program handler when an error occurs.
Syntax:
ON BREAK CALL handler
call SUB program handler when CTRL-C is detected. The handler may call RESUME NEXT to ignore the CTRL-C signal.
Syntax:
OPTION BREAK [ ( ON | OFF ) ]
instructs the compiler to add checks for CTRL-C/D in loops, subprogram calls so programs can be interrupted when they run into an endless loop or recursion. Enabled by default, disable to gain a bit of performance.
Syntax:
OPTION DEBUG [ ( ON | OFF ) ]
instructs the compiler to generate debug code (i.e. TRACE etc.) or not
Syntax:
OPTION EXPLICIT [ ( ON | OFF ) ]
instructs the compiler to require variable declaration
Syntax:
OPTION PRIVATE [ ( ON | OFF ) ]
make declared variables, types, functions and subprograms private (not exported) by default
Syntax:
PEEK "(" address ")"
return a byte from memory at the specified address
Syntax:
PEEKW "(" address ")"
return a word (16 bits) from memory at the specified address
Syntax:
PEEK "(" address ")"
return a long (32 bits) from memory at the specified address
Syntax:
POKE address, value
store byte value at the specified memory address
Syntax:
POKEW address, value
store word (16 bits) value at the specified memory address
Syntax:
POKEL address, value
store long (32 bits) value at the specified memory address
Syntax:
PRINT [ expression ( [ ";" | "," ] expression )* ]
print the listed expressions to the screen. ";" means no space, "," means skip to next 9 col tab, ";" or "," at the end of the line mean no newline is printed.
Syntax:
PRINT "#" expFNo "," [ expression ( [ ";" | "," ] expression )* ]
print the listed expressions to given file stream. ";" means no space, "," means skip to next 9 col tab, ";" or "," at the end of the line mean no newline is printed.
Syntax:
PROPERTY ident1 "." ident2 [ parameterList ] [ AS typeDesc ]
Implement a UDT property setter or getter.
Example:
TYPE myc1
field1 AS INTEGER
DECLARE PROPERTY p1 AS INTEGER
DECLARE PROPERTY p1 (BYVAL f AS INTEGER)
END TYPE
PROPERTY myc1.p1 AS INTEGER
return field1
END PROPERTY
PROPERTY myc1.p1 (BYVAL f AS INTEGER)
field1 = f
END PROPERTY
Syntax:
RANDOMIZE seed
re-initialize the built-in pseudo random number generator to the given seed.
Syntax:
READ varDesignator ( "," varDesignator )*
read values from the DATA section and assign them to one or more variables
Syntax:
REDIM [PRESERVE] [SHARED] arrayId ([[lbound TO] ubound [ "," ...]]) [ AS datatype ] [, ...]
declare or resize a dynamic array. Previous values are erased unless the PRESERVE keyword is specified.
Syntax:
RESTORE [ dataLabel ]
restore data read pointer to the specified label, if no label is specified, restore read pointer to the first data statement.
Syntax:
RETURN [ expr ]
return from a subroutine or function. In case of return from a function, expr specifies the return value
Syntax:
RIGHT$ "(" s "," n)
returns the rightmost n characters in s
Syntax:
RND ([n])
returns a random number with a value between 0 (inclusive) and 1 (exclusive).
* n = 0: return the last value returned
* n < 0: reset the pseudo random number generator to the built-in seed
* n > 0: the sequence of numbers generated will not change unless RANDOMIZE is initiated
Syntax:
SELECT CASE expr
CASE caseExpr ( "," caseExpr2 )*
statements1
[ CASE caseExpr3 ( "," caseExpr4 )*
statements2 ]
...
[ CASE ELSE
statementsN ]
END SELECT
determine the program flow by comparing the value of an expression to specific CASE values
Case Expression syntax:
( expression [ TO expression ]
| IS ( '=' | '>' | '<' | '<>' | '<=' | '>=' ) expression )
Syntax:
SGN "(" x ")
returns the sign of a numeric expression
* x = 0: return 0
* x < 0: return -1
* x > 0: return 1
Syntax:
SIN "(" a ")
obtain the sine of the floating point number
Syntax:
SIZEOF "(" ident ")
Returns the memory size in bytes of a given variable or named type
Syntax:
SLEEP FOR seconds
Suspend program for the specified number of seconds (floating point value, so fractions of seconds are supported).
Syntax:
SPACE$ "(" n ")"
returns a string of space characters of a given length
Syntax:
SPC "(" n ")"
returns a string of space characters of a given length
Syntax:
SQR "(" x ")"
obtain the square root of the floating point number
Syntax A:
STATIC Identifier AS TypeIdentifier [ "(" arrayDimensions ")" ] [ "=" expr] ( "," Indetifier2 AS ... )*
Syntax B:
STATIC AS TypeIdentifier [ "(" arrayDimensions ")" ] Identifier [ "=" expr] ( "," Identifier2 ... )*
declare variable(s) as static.
Syntax:
STR$ "(" expr ")"
return a string representation (the same one that is used in PRINT output) of a given numeric expression
Syntax:
STRING$ "(" l "," s ")"
returns a string of characters using the first character of the string of a given length
Example:
DIM AS STRING s, s1
s = "Monday"
s1 = STRING$(4, s)
ASSERT s1="MMMM"
Syntax:
SWAP a "," b
exchange the values of two variables
Example:
OPTION EXPLICIT
DIM f AS INTEGER = 42
DIM g AS INTEGER = 23
SWAP f, g
TRACE f, g
Syntax:
SYSTEM
exit the program (same as END)
Syntax:
TAN "(" a ")"
obtain the tangent of the floating point number
Syntax:
TIME$
returns a string representation of the current time
time format used is hh:mm:ss
Syntax:
TIMER "(" ")"
returns the number of seconds past the previous midnite as a SINGLE float value
Syntax:
TRACE [ expression ( [ ";" | "," ] expression )* ]
print the listed expressions to the debug console. ";" means no space, "," means skip to next 9 col tab, ";" or "," at the end of the line mean no newline is printed.
Syntax:
TYPE ident AS typedesc [ "(" arrayDimensions ")" ]
Example:
TYPE a_t AS INTEGER (STATIC 9)
declares a new named UDT
Syntax:
TYPE ident [ EXTENDS baseCls ]
[PRIVATE:|PUBLIC:|PROTECTED:]
var [ "(" arrayDimensions ")" ] AS typedesc
AS typedesc var [ "(" arrayDimensions ")" ]
DECLARE (SUB|FUNCTION|CONSTRUCTOR) ...
...
END TYPE
declares a new record UDT
Syntax:
UBOUND "(" array [ "," dimension ] ")"
return the upper bound for the given array dimension.
Syntax:
UCASE$ "(" s ")"
return an all-uppercase version of s
Syntax:
VAL "(" str ")"
return the floating-point representation of the given string argument str.
Syntax:
VALINT "(" str ")"
return the integer representation of the given string argument str.
Syntax:
VALUINT "(" str ")"
return the unsigned integer representation of the given string argument str.
Syntax:
VALLNG "(" str ")"
return the long representation of the given string argument str.
Syntax:
VALULNG "(" str ")"
return the unsigned long representation of the given string argument str.
Syntax:
VARPTR "(" designator ")"
returns the address of a variable
Syntax:
WHILE expression
<code>
WEND
repeat loop body while expression evaluates to TRUE
see WHILE ... WEND
Syntax:
WRITE [ expression ( [ ";" | "," ] expression )* ]
print the listed expressions to the screen, separated by comma. Numeric values will be printed without a leading space, string values will be enclosed in "".
Syntax:
WRITE "#" expFNo "," [ expression ( [ ";" | "," ] expression )* ]
print the listed expressions to given file stream, separated by comma. Numeric values will be printed without a leading space, string values will be enclosed in "".