Mikroelektronika MIKROE-350 Fiche De Données

Page de 526
MODULES
In mikroBasic PRO for AVR, each project consists of a single project file and one or
more module files. The project file, with extension 
.mbpav
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 AVR includes modules by means of the include clause. It con-
sists 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 pro-
gram (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. 
124
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroBasic PRO for AVR
CHAPTER 5