- %ifdef {def_name} conditional translation. Following lines are generated to output only if macro {def_name} is defined. This command must be finished by command %endif, %else or %elif.
- %ifndef {def_name} conditional translation. Following lines are generated to output only if macro {def_name} is not defined. This command must be finished by command %endif, %else or %elif.
- %if {condition} conditional translation. Following lines are generated to output only if condition {condition} is true. This command must be finished by command %endif, %else or %elif.
- %elif {condition} conditional translation. Following lines are generated to output only if condition {condition} is true. This command must be finished by command %endif, %else or %elif.
- %else conditional translation. Following lines are generated to output only if all previous conditions of %if commands were false. This command must be finished by command %endif.
- %endif ends conditional translation.
Example:
%ifndef Macro1
%ifdef Macro1Value
%error Macro1Value is defined without Macro1
%else
%error Macro1 is not defined
%endif
%elif Macro1='yes'
%define Macro1Value 1
%elif Macro1='no'
%define Macro1Value 0
%else
%error Unrecognized value in Macro1
%endif
Macros definition:
- %define {def_name} [{text}] - This command defines a new local macro called {def_name} with value {text}. The macro will exist only during processing of current driver. The command raises error if macro already exists with another value. Macro can be defined without value.
- %define! {def_name} {text} - This command is same as the previous one, but if the macro already exists, it is redefined without any error.
- %define_prj {def_name} {text} - Defines new global macro with value {text}. This macro will be defined to the end of generation of all drivers.
- %undef {def_name} removes macro definition. This command raises error if macro {def_name} does not exits.
- %undef!{def_name} removes macro definition. If macro does not exist, it does nothing.
Example:
%define MyFirstMacroDefinition Value
%define! MyFirstMacroDefinition Value redefinition
%undef MyFirstMacroDefinition
%undef! MyFirstMacroDefinition
Including external file:
%include {filename} includes file {filename} to the current position of text. {filename} must be with relative path from directory ProcessorExpert\Drivers\.
%include {filename}({par1},{par2},..) is the same as simple %include command, and additionally parameters are accessible using macros %1, %2, ... Parameter par? is defined as all characters between separators (,,,).
Example:
%include SubProg.prg (Value)
contents of ProcessorExpert\Drivers\SubProg.prg
%if MyMacro!=%1
%define! MyMacro %1
%endif
Comments and text formatting:
- %+[{string1}[{string2}]]{text} appends {string2}{text} to the end of previous generated line. But if the new line is too long it produces another new line: {string1}{text}. {strings} are not required and they must be closed with quotation marks.
- %>{number} sets the current output position of the text to column {number}. At least one space will be inserted.
- %- comments to the end of line.
Example:
%- Comment: This is assembler formatting
%>20 ADD A,20
%>20 SUB A,B
Errors:
The following messages are displayed in Processor Expert Error window.
- %error {text} produces error message {text}.
- %error!{text} the same as %error and the error message will contain file name and line number.
- %error^{text} the same as %error and generation is stopped for current driver.
- %warning {text} produces warning message. If a TST file for current component exists, the warning from the driver will not be displayed.
- %hint {text} produces hint. If a TST file for current component exists, the hint from driver will not be displayed.
Example:
%error I'm sorry but this driver is not finished yet.
%warning This configuration is not useful.
%error! Internal error in the driver. Please contact your distributor.
Lists:
Macroprocessor supports macros with list as a value. You can have several items in a list.
- %add {def_list} {text} add item {text} to the list {def_list}. If the list is not defined then it will be created. An item cannot be empty string. There is duplicate checking, if the item is already in the list, this command does NOT add a new one. List {def_list} is a global macro for project. But you cannot modify lists defined by Processor Expert.
- %append {def_list} {text} add item {test} th the list {def_list}. If the list is not defined, then it will be created. An item cannot be empty string. There is no duplicate checking; if the item is already in the list; this command adds a new one. List {def_list} is a global macro for project. But you cannot modify lists defined by Processor Expert.
- %apploc {def_list} {text} the same as %append, but the macro is local - defined only for current driver.
- %addloc {def_list} {text} the same as add, but the macro is local - defined only for current driver.
- %for {def_name} from {def_list}
{block of text}
%endfor {block of text} is several lines of text. This block will be generated for each value in the list {def_list} and during each generation the macro {def_name} will have value of one item from list. Macro {def_value} cannot be defined before this command and will not be defined after the end of command.
You can use notation: [{number}..{number}] instead {def_list} macro.
- for {def_name} fromdown {def_list}
{block of text}
%endfor the same as command for ... from ... , but the items from the list are selected from the last item to the first one.
Example:
%apploc MyFirstList Item1
%apploc MyFirstList Item2
%apploc MyFirstList Item2
%for i from MyFirstList
Report: List Item is "%i"
%endfor
%for i from [0..7]
%i
%endfor
Expressions:
Evaluation of expressions is done in real numbers. For integer operations, the value is rounded to 32-bit signed integer.
- %:{def_name}{operator}{number}[;{text}] text is ignored. Expression is evaluated and the result is assigned to macro
def_name
- %:{def_name}?={number},{number1}:{number_1},{number2}:{number_2}, .. ; convert value number using table: if number is equal to number1 then the result is number_1, if number is equal to number2 then result is number_2, etc. The result is assigned to macro def_name. Error is reported to Processor Expert Error window if the value is not found in the table.
Example:
%:a=0
%:a+=1
%:b?=%a,0:3.1415,1:6.2830
Subsections:
- %INITIALIZATION - Component initialization code. This code will be inserted into CPU initialization procedure
- %INTERFACE - Component header file. This file must contain interface of all selected methods
- %IMPLEMENTATION - Component implementation file. This file must contain implementation of all selected methods
- %INTERFACE {eventname} - Interface of selected event. This part will be inserted into interface of events module
- %IMPLEMENTATION {eventname} - Implementation of selected event. This part will be inserted into events implementation module
- %FILE [{dir}]{filename} - Text from this subsection will be saved to the specified file