User manual

mikroBasic PRO for PIC32
MikroElektronika
193
Interface Section
Part of the module above the keyword implements is referred to as interface section. Here, you can place global
declarations (constants, variables, labels, routines, structures) for the project.
Do not dene routines in the interface section. Instead, state the prototypes of routines (from implementation section)
that you want to be visible outside the module. Prototypes must exactly match the declarations.
Implementation Section
Implementation section hides all the irrelevant innards from other modules, allowing encapsulation of code.
Everything declared below the keyword implements is private, i.e. has its scope limited to the le. When you declare
an identier in the implementation section of a module, you cannot use it outside the module, but you can use it in any
block or routine dened within the module.
By placing the prototype in the interface section of the module (above the implements) you can make the routine
public, i.e. visible outside of module. Prototypes must exactly match the declarations.
Variables
Variable is an object whose value can be changed during the runtime. Every variable is declared under unique name
which must be a valid identier. This name is used for accessing the memory location occupied by a variable.
Variables are declared in the declaration part of the le or routine — each variable needs to be declared before being
used. Global variables (those that do not belong to any enclosing block) are declared below the include statements,
above the label main.
Specifying a data type for each variable is mandatory. Syntax for variable declaration is:
dim identier_list as type
Here, identier_list is a comma-delimited list of valid identiers, and type can be any data type.
For more details refer to Types and Types Conversions. For more information on variables’ scope refer to the chapter
Scope and Visibility.
Here are a few examples:
dim i, j, k as byte
dim counter, temp as word
dim samples as longint[100]
External Modier
Use the external modier to indicate that the actual place and initial value of the variable, sub function or sub
procedure body, is dened in a separate source code module.