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 dene 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 identier in the implementation section of a module, you cannot use it outside the module, but you can use it in any
block or routine dened 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 identier. 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 identier_list as type
Here, identier_list is a comma-delimited list of valid identiers, 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 Modier
Use the external modier to indicate that the actual place and initial value of the variable, sub function or sub
procedure body, is dened in a separate source code module.