User`s manual

mikroBASIC
- Basic Compiler for Microchip PIC microcontrollers
46
mikroBASIC
MikroElektronika: Development tools - Books - Compilers
making it simple...
page
Aside from the include clause, program consists entirely of declarations and
statements, which are organized into blocks.
Names of variables, constants, types, procedures, functions, programs and units
are called identifiers (numeric constant like 321 is not an identifier).
Identifiers need to be declared before you can use them. Only exceptions are few
predefined types, library functions and procedures, PIC MCU SFR ( PIC Special
Function Registers), and constants; these are understood by the compiler automati-
cally.
Declaration defines an identifier and, where appropriate, allocates memory for it.
For example:
dim Right as word
declares a variable called Right that holds a word value, while:
sub function Each(dim X as integer, dim Y as integer) as integer
declares a function called Each which collects two integers as arguments and
returns an integer.
Each declaration ends with a semicolon (separator). When declaring several vari-
ables, constants, or types at the same time, you need to write the appropriate
reserved word only once :
dim Height as integer
dim Description as string[10]
The syntax and placement of a declaration depends on the kind of identifier you
are defining. In general, declarations take place only at the beginning of a block,
or at the beginning of the implementation section of a unit (after the include
clause). Specific conventions for declaring variables, constants, types, functions,
and so forth can be found in the appropriate chapters.
DECLARATIONS AND STATEMENTS
Declarations
MikroElektronika: Development tools - Books - Compilers