Language Keywords and Operators

Keywords

KeywordDescriptionUsage
INCLUDEInclude code from an external file.You can reference environment variables inside the include string with this syntax ${env_var}INCLUDE "STRING_LITERAL.bas"
INCLUDE ONCETells the compiler to only include the current file once.INCLUDE ONCE
IFExecutes a block of code if an expression is true.ELSEIF can be substituted for ELSE IFIF <EXPRESSION> THEN ' ..... ELSEIF <EXPRESSION> THEN ' ..... ELSE ' ..... END IF
SELECTExecutes a block of code if a case is equal to the selection case.SELECT CASE <EXPRESSION> CASE <EXPRESSION> ' ..... DEFAULT ' ..... END SELECT
DO / LOOPExecutes a block of code while a condition is true or until a condition is met.DO ' ..... LOOP {UNTIL | WHILE} <EXPRESSION>
WHILE / WENDExecutes a block of code while a condition is true.WHILE <EXPRESSION> ' ..... WEND
FORSets a counter variable to an initial value and executes a block of code until the counter variable has reached a peak value.FOR <ID> = <EXPRESSION> TO <EXPRESSION> {STEP} <EXPRESSION> ' ..... NEXT
EXITExits a loop.EXIT { DO | FOR | WHILE }
CONTINUEJumps back to the start of a loop.CONTINUE
FUNCTIONCreates a function.FUNCTION <ID> ( {BYREF} <ID>, ... ) ' ..... RETURN <EXPRESSION> END FUNCTION
SUBCreates a Sub Routine.SUB <ID> ( {BYREF} <ID>, ... ) ' ..... {RETURN} END SUB
PRINTOutputs text to a console.PRINT <EXPRESSION>
ENDEnds a program. Add a number expression after END to set the exit code.END END <EXPRESSION>
DIMCreates a variable or array.DIM <ID> {[} <EXPRESSION> {]}
REDIMResizes an array.REDIM <ID> {[} <EXPRESSION> {]}
DELETEDeletes an array.DELETE <ID>
TRUEConstant that evaluates to NOT 0.TRUE
FALSEConstant that evaluates to 0.FALSE

Operators

OperatorDescriptionExample
+Addition — adds two numbers.1 + 2
-Subtraction — subtracts one number from another.1 - 2
*Multiplication — multiplies two numbers.1 * 2
/Division — divides one number by another.1 / 2
^Exponent — raises one number to the power of another.1^2
>Greater — returns TRUE if the first number is greater than the second.1 > 2 → FALSE
2 > 1 → TRUE
<Less — returns TRUE if the first number is less than the second.1 < 2 → TRUE
2 < 1 → FALSE
>=Greater or equal — returns TRUE if the first number is greater than or equal to the second.1 >= 2 → FALSE
1 >= 1 → TRUE
<=Less or equal — returns TRUE if the first number is less than or equal to the second.1 <= 2 → TRUE
2 <= 1 → FALSE
=Equal — returns TRUE if both values are equal.1 = 2 → FALSE
1 = 1 → TRUE
<>Not equal — returns TRUE if both values are not equal.1 <> 2 → TRUE
1 <> 1 → FALSE
MODModulus — returns the remainder of the first number divided by the second.1 MOD 2 → 1
SHLShift left — shifts the bits in a number to the left.1 SHL 2 → 4
SHRShift right — shifts the bits in a number to the right.4 SHR 2 → 1
ANDConducts AND comparison of two values.1 AND 1
ORConducts OR comparison of two values.1 OR 1
XORConducts exclusive-OR comparison of two values.1 XOR 1
NOTConducts NOT operation on a value.NOT 1
+ (string)String add — combines two string values."HELLO"+"WORLD"
:End of instruction — tells the compiler to end the current instruction and read the following code as a new instruction.X = 5: PRINT X

Escape Characters

EscapeDescription
\\Inserts a \ into a string.
\n Inserts a new-line into a string.
\bInserts a backspace into a string.
"  /  \qInserts a quotation mark into a string.
\tInserts a tab into a string.
\0Inserts a null character into a string.
\aInserts an alert bell into a string.
\vInserts a vertical tab into a string.
\fInserts a form feed into a string.
\rInserts a carriage return into a string.