
SOME BASIC KEYWORDS
Languages maintain certain reserved words called Keywords that
are used to tell the compiler or interpreter what to do. These words cannot be used as a variables;
they are available to the programmer only in the sense of the language.
Print is a keyword and it is used by Basic to send output to the screen, file, or printer.
If we write a simple program to add up the sum of ten numbers we cannot store the answer in a
variable named Print, because Print is a Basic language command.
Here is a list of Keywords found nearly always in any implementation of BASIC
from the DOS days; and also used in modern GUI BASICS. Some BASICS have a longer list of
keywords, but these arecommon to LibertyBasic. The keywords pertaining largely to Graphical
Interface interaction are not in this list, but we will add them later.
| Keyword | Brief Description of Keyword |
| ABS( n ) | absolute value of a number |
| BEEP | rings bell |
| CHR$ ( n ) | A return character of ascii value n |
| CLOSE #h | closes a file or window with handle #h |
| CLS | clears a program's mainwindow |
| DATE$( ) | returns string with current date |
| DIM array( ) | dimensions an array( ) |
| EOF( #h ) | end-of-file marker for #h |
| END | ends a programs execution |
| FOR...NEXT | performs a looping action |
| GET #h, n | get a random access record n for #h |
| GOSUB label | call subroutine label |
| GOTO label | branch to label |
| HEXDEC("value") | convert a hexadecimal string to a decimal number |
| IF...THEN | perform conditional action(s) |
| IF THEN ELSE | perform conditional action(s) |
| INPUT | get data from keyboard, file or button |
| INPUT$( #h, n ) | get n chars from specified handle #h |
| INSTR(a$,b$,n) | search for a string b$ in a$, with optional start nth character |
| INT( n ) | integer portion of n |
| KILL s$ | delete file named s$ |
| LEFT$( s$, n ) | first n characters of s$ |
| LEN( s$ ) | length of s$ |
| LET var = expr | assign value of expr to var |
| LINE INPUT | get next line of text from file |
| LPRINT | print to hard copy |
| MID$( ) | return a substring from a string |
| OPEN | open a file, window, or DLL |
| print to a file or window | |
| PUT #h, n | puts a random access record n for #h |
| REDIM | redimensions an array and resets it contents |
| REM | adds a remark to a program |
| RIGHT$( s$, n ) | n rightmost characters of s$ |
| RND( n ) | return pseudo-random seed |
| RUN s$, mode | run an external program s$, with optional mode |
| STR$( n ) | returns the string equivalent of n |
| TRACE n | sets debug trace level to n |
| VAL( s$ ) | returns numeric equivalent of string s$ |
| WHILE...WEND | performs looping action |
Most implementations of BASIC contain a few more non-GUI keywords than this, but this is representative. Download LibertyBasic if you havent already done so and we will begin s simple tour of BASIC....
This page maintained by
OssaWebPresence
Update: 11/1/2002