User manual

190
mikoBasic PRO for PIC32
MikroElektronika
‘ functions declarations
sub function sub_function_name([dim byref] [const] ParamName as [^]type, [dim byref]
[const] ParamName2, ParamName3 as [^]type) as [^]type [ilevel 0x123] [overload]
[forward]
<local declarations>
...
end sub
end.
Note: Sub functions and sub procedures must have the same declarations in the interface and implementation section.
Otherwise, compiler will report an error.
Scope and Visibility
Scope
The scope of an identier is a part of the program in which the identier can be used to access its object. There are
different categories of scope, which depends on how and where identiers are declared:
Visibility
The visibility of an identier is that region of the program source code from which legal access to the identier’s
associated object can be made.
Scope and visibility usually coincide, though there are circumstances under which an object becomes temporarily
hidden by the appearance of a duplicate identier, i.e. the object still exists but the original identier cannot be used to
access it until the scope of the duplicate identier is ended.
Technically, visibility cannot exceed scope, but scope can exceed visibility.
Place of declaration Scope
Identier is declared in the declaration section of the
main module, out of any function or procedure
Scope extends from the point where it is declared to the end of the cur-
rent le, including all routines enclosed within that scope. These identi-
ers have a le scope and are referred to as globals.
Identier is declared in the function or procedure Scope extends from the point where it is declared to the end of the cur-
rent routine. These identiers are referred to as locals.
Identier is declared in the interface section of the
module
Scope extends the interface section of a module from the point where
it is declared to the end of the module, and to any other module or pro-
gram that uses that module. The only exception are symbols which have
a scope limited to the le in which they are declared.
Identier is declared in the implementation sec-
tion of the module, but not within any function or
procedure
Scope extends from the point where it is declared to the end of the mod-
ule. The identier is available to any function or procedure in the module.