Language Keywords and Operators
Keywords
| Keyword | Description | Usage |
|---|---|---|
| INCLUDE | Include code from an external file.You can reference environment variables inside the include string with this syntax ${env_var} | INCLUDE "STRING_LITERAL.bas" |
| INCLUDE ONCE | Tells the compiler to only include the current file once. | INCLUDE ONCE |
| IF | Executes a block of code if an expression is true.ELSEIF can be substituted for ELSE IF | IF <EXPRESSION> THEN
' .....
ELSEIF <EXPRESSION> THEN
' .....
ELSE
' .....
END IF |
| SELECT | Executes a block of code if a case is equal to the selection case. | SELECT CASE <EXPRESSION>
CASE <EXPRESSION>
' .....
DEFAULT
' .....
END SELECT |
| DO / LOOP | Executes a block of code while a condition is true or until a condition is met. | DO
' .....
LOOP {UNTIL | WHILE} <EXPRESSION> |
| WHILE / WEND | Executes a block of code while a condition is true. | WHILE <EXPRESSION>
' .....
WEND |
| FOR | Sets 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 |
| EXIT | Exits a loop. | EXIT { DO | FOR | WHILE } |
| CONTINUE | Jumps back to the start of a loop. | CONTINUE |
| FUNCTION | Creates a function. | FUNCTION <ID> ( {BYREF} <ID>, ... )
' .....
RETURN <EXPRESSION>
END FUNCTION |
| SUB | Creates a Sub Routine. | SUB <ID> ( {BYREF} <ID>, ... )
' .....
{RETURN}
END SUB |
| Outputs text to a console. | PRINT <EXPRESSION> | |
| END | Ends a program. Add a number expression after END to set the exit code. | END
END <EXPRESSION> |
| DIM | Creates a variable or array. | DIM <ID> {[} <EXPRESSION> {]} |
| REDIM | Resizes an array. | REDIM <ID> {[} <EXPRESSION> {]} |
| DELETE | Deletes an array. | DELETE <ID> |
| TRUE | Constant that evaluates to NOT 0. | TRUE |
| FALSE | Constant that evaluates to 0. | FALSE |
Operators
| Operator | Description | Example |
|---|---|---|
| + | 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 → FALSE2 > 1 → TRUE |
| < | Less — returns TRUE if the first number is less than the second. | 1 < 2 → TRUE2 < 1 → FALSE |
| >= | Greater or equal — returns TRUE if the first number is greater than or equal to the second. | 1 >= 2 → FALSE1 >= 1 → TRUE |
| <= | Less or equal — returns TRUE if the first number is less than or equal to the second. | 1 <= 2 → TRUE2 <= 1 → FALSE |
| = | Equal — returns TRUE if both values are equal. | 1 = 2 → FALSE1 = 1 → TRUE |
| <> | Not equal — returns TRUE if both values are not equal. | 1 <> 2 → TRUE1 <> 1 → FALSE |
| MOD | Modulus — returns the remainder of the first number divided by the second. | 1 MOD 2 → 1 |
| SHL | Shift left — shifts the bits in a number to the left. | 1 SHL 2 → 4 |
| SHR | Shift right — shifts the bits in a number to the right. | 4 SHR 2 → 1 |
| AND | Conducts AND comparison of two values. | 1 AND 1 |
| OR | Conducts OR comparison of two values. | 1 OR 1 |
| XOR | Conducts exclusive-OR comparison of two values. | 1 XOR 1 |
| NOT | Conducts 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
| Escape | Description |
|---|---|
| \\ | Inserts a \ into a string. |
| \n | Inserts a new-line into a string. |
| \b | Inserts a backspace into a string. |
| " / \q | Inserts a quotation mark into a string. |
| \t | Inserts a tab into a string. |
| \0 | Inserts a null character into a string. |
| \a | Inserts an alert bell into a string. |
| \v | Inserts a vertical tab into a string. |
| \f | Inserts a form feed into a string. |
| \r | Inserts a carriage return into a string. |