Mikroelektronika MIKROE-724 データシート

ページ / 726
194
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
Modules
In mikroBasic PRO for dsPIC30/33 and PIC24, each project consists of a single project file and one or more module 
files. The project file, with extension 
.mbpds
 contains information on the project, while modules, with extension 
.mbas
contain the actual source code. See Program Organization for a detailed look at module arrangement.
Modules allow you to:
 
- break large programs into encapsulated modules that can be edited separately, 
 
- create libraries that can be used in different projects, 
 
- distribute libraries to other developers without disclosing the source code. 
Each module is stored in its own file and compiled separately; compiled modules are linked to create an application. To 
build a project, the compiler needs either a source file or a compiled module file for each module.
Include Clause
mikroBasic PRO for dsPIC30/33 and PIC24 includes modules by means of the 
include
 clause. It consists of the 
reserved word 
include
, followed by a quoted module name. Extension of the file should not be included.
You can include one file per 
include
 clause. There can be any number of the 
include
 clauses in each source file, 
but they all must be stated immediately after the program (or module) name.
Here’s an example:
program MyProgram
include “utils”
include “strings”
include “MyUnit”
...
For the given module name, the compiler will check for the presence of 
.mcl
 and 
.mbas
 files, in order specified by 
search paths.
 
- If both 
.mbas
 and 
.mcl
 files are found, the compiler will check their dates and include the newer one in  
 
  the project. If the 
.mbas
 file is newer than the 
.mcl
, then 
.mbas
 file will be recompiled and new 
.mcl
 will  
 
  be created, overwriting the old 
.mcl
 
- If only the 
.mbas
 file is found, the compiler will create the 
.mcl
 file and include it in the project; 
 
- If only the 
.mcl
 file is present, i.e. no source code is available, the compiler will include it as found; 
 
- If none of the files found, the compiler will issue a “File not found” warning.
Main Module
Every project in mikroBasic PRO for dsPIC30/33 and PIC24 requires a single main module file. The main module is 
identified by the keyword 
program
 at the beginning. It instructs the compiler where to “start”.
After you have successfully created an empty project with Project Wizard, Code Editor will display a new main module. 
It contains the bare-bones of the program: