You are on page 1of 2

GW-BASIC Statements, Functions, Commands, and Variables

A GW-BASIC program is made up of several elements: keywords, commands, statements, functions, and variables.

2.4.1 Keywords
GW-BASIC keywords, such as PRINT, GOTO, and RETURN have special significance for the GW-BASIC Interpreter. GW-BASIC interprets keywords as part of statements or commands. Keywords are also called reserved words. They cannot be used as variable names, or the system will interpret them as commands. However, keywords may be embedded within variable names. Keywords are stored in the system as tokens (1- or 2-byte characters) for the most efficient use of memory space.

2.4.2 Commands
Commands and statements are both executable instructions. The difference between commands and statements is that commands are generally executed in the direct mode, or command level of the interpreter. They usually perform some type of program maintenance such as editing, loading, or saving programs. When GW-BASIC is invoked and the GW-BASIC prompt, Ok, appears, the system assumes command level.

2.4.3 Statements
A statement, such as ON ERROR...GOTO, is a group of GW-BASIC keywords generally used in GW-BASIC program lines as part of a program. When the program is run, statements are executed when, and as, they appear.

2.4.4 Functions
The GW-BASIC Interpreter performs both numeric and string functions. 2.4.4.1 Numeric Functions The GW-BASIC Interpreter can perform certain mathematical (arithmetical or algebraic) calculations. For example, it calculates the sine (SIN), cosine (COS), or tangent (TAN) of angle x. Unless otherwise indicated, only integer and single-precision results are returned by numeric functions. 2.4.4.2 String Functions

String functions operate on strings. For example, TIME$ and DATE$ return the time and date known by the system. If the current time and date are entered during system start up, the correct time and date are given (the internal clock in the computer keeps track). 2.4.4.3 User-Defined Functions Functions can be user-defined by means of the DEF FN statement. These functions can be either string or numeric.

2.4.5 Variables
Certain groups of alphanumeric characters are assigned values and are called variables. When variables are built into the GW-BASIC program they provide information as they are executed. For example, ERR defines the latest error which occurred in the program; ERL gives the location of that error. Variables can also be defined and/or redefined by the user or by program content. All GW-BASIC commands, statements, functions, and variables are individually described in the GW-BASIC User's Reference.

You might also like