Mikroelektronika MIKROE-724 データシート

ページ / 726
mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
195
program MyProject
‘ main procedure
main:
  ‘ Place program code here
end.
Other than comments, nothing should precede the keyword 
program
. After the program name, you can optionally 
place the 
include
 clauses.
Place all global declarations (constants, variables, labels, routines, structures) before the label 
main
.
Other Modules
Modules other than main start with the keyword 
module
. Newly created blank module contains the bare-bones:
module MyModule
implements
end.
Other than comments, nothing should precede the keyword 
module
. After the module name, you can optionally place 
the 
include
 clauses.
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 define 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 file. When you declare 
an identifier in the implementation section of a module, you cannot use it outside the module, but you can use it in any 
block or routine defined 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.