Declarations |
Top Previous Next |
Before a variable can be used, it must be declared. The integer variable declaration has the general form:
integer NAME, NAME, ... NAME;
For example:
integer Guess, Number, Frog;
This declaration tells the compiler that the variables Guess, Number, and Frog are used later in the program.
The word "integer" is a command word. Command words are words that have special meaning to the compiler. They are in lowercase letters. This, for instance, allows you to also use the word "Integer" as a variable name.
Since the compiler looks at only the first three characters of a command word, they can be abbreviated. For example, these are equivalent:
integer int
Variables that contain real numbers are declared similar to the way integers are declared:
real NAME, NAME, ... NAME;
In XPL0 all named things, such as variables, procedures, and intrinsics, must be declared before they can be used. The rules for creating variable names, such as starting with a capital letter, apply to all names. |