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 identier is a part of the program in which the identier can be used to access its object. There are
different categories of scope, which depends on how and where identiers are declared:
Visibility
The visibility of an identier is that region of the program source code from which legal access to the identier’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 identier, i.e. the object still exists but the original identier cannot be used to
access it until the scope of the duplicate identier is ended.
Technically, visibility cannot exceed scope, but scope can exceed visibility.
Place of declaration Scope
Identier 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.
Identier 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 identiers are referred to as locals.
Identier 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.
Identier 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 identier is available to any function or procedure in the module.