User manual
234
mikoPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
Directives #IFDEF and #IFNDEF are terminated with the #ENDIF directive and can have an optional #ELSE clause:
{$IFDEF ag}
<block of code>
{$ELSE}
<alternate block of code>
{$ENDIF}
First, #IFDEF checks if ag is dened by means of #DEFINE. If so, only <block of code> will be compiled.
Otherwise, <alternate block of code> will be compiled. #ENDIF ends the conditional sequence. The result of
the preceding scenario is that only one section of code (possibly empty) is passed on for further processing.
The processed section can contain further conditional clauses, nested to any depth; each #IFDEF must be matched
with a closing #ENDIF.
Here is an example:
// Uncomment the appropriate ag for your application:
//{$DEFINE resolution10}
//{$DEFINE resolution12}
{$IFDEF resolution10}
// <code specic to 10-bit resolution>
{$ELSE}
{$IFDEF resolution12}
// <code specic to 12-bit resolution>
{$ELSE}
// <default code>
{$ENDIF}
{$ENDIF}
Unlike #IFDEF, #IFNDEF checks if ag is not dened by means of #DEFINE, thus producing the opposite results.
Include Directive $I
The $I parameter directive instructs mikroPascal PRO for dsPIC30/33 and PIC24 to include the named text le in
the compilation. In effect, the le is inserted in the compiled text right after the {$I lename} directive. If lename
does not specify a directory path, then, in addition to searching for the le in the same directory as the current unit,
mikroPascal PRO for dsPIC30/33 and PIC24 will search for le in order specied by the search paths.
To specify a lename that includes a space, surround the le name with quotation marks: {$I “My le”}.
There is one restriction to the use of include les: An include le can’t be specied in the middle of a statement part. In
fact, all statements between the begin and end of a statement part must exist in the same source le.
See also Predened Project Level Denes.