The format of the text macro definion is as follows:
%DEF(<macro-name>=<macro-body>) %*DEF(<macro-name>=<macro-body>) %*DEF(<macro-name>(<param1> [ , <paramx> ... ] )=<macro-body>)
One can use each of the 3 forms of the command: %DEF, %DEFINE and %DEFMAC.
An asterisk after the % sign ( %*DEF ) means: the body of the macro will be read without
further macro processing - % signs inside the body remain unchanged.
When invoking the macro, it is either with or without parameters:
%<macro-name>; %<macro-name>() %<macro-name>(); %<macro-name>(<parameter-list) %<macro-name>(<parameter-list);
If the macro invocation is without parameters, one can terminate the macro name by a semicolon. The semicolon will be 'consumed' by the macro invcation - it is removed from the input text. The construct will be replaced by the macro body. Placing an empty parenthesys after the <macro-name> is a possibility. When using a parenthesys after the <macro-name> for the parameters (even if there is no actual parameter) terminates the macro invocation, there is no need to place an additional semicolon after the closing parenthesys, but you might to do so. Additionally, you can omit the semicolon after the <macro-name> when invoking a macro without parameters, if the next chracter after the <macro-name> is not a name-character (not a letter, digit or underscore). If this following character is a semicolon, it will be always 'consumed', removed from the input, otherwise the terminating not-name character remains, and will be used after the macro body is included.
Names starting with % are used for the macro processing. There are a few predefined special macros - see the page Text macro processing. Macro names defined by the previous %DEF() or %*DEF() occurrences are the already defined macros, they can be invoked on any later places. Additionally, macro parameters can be embedded into the macro body by using the parameter name after a % sign. Similarly to the macro invocations without parameters the parameter usage have to be terminated by a non-name character. The semicolon is removed from the macro body when used as a parameter name termination, oher non-name characters remain unchanged, and will be used by the further processing.
Macro bodies can contain further macro invocations - so a certain macro body can be called from a deeper level, having multiple parameter sets up in invocations chain. Using a macro parameter ( having it's name after an asterisk ) will use the nearest (deepest) invocation that parameter is contained in the <parameter-list> of the given macro. So, when different macros use different parameter names, and they are calling each other, the deepest macro body can use not only the actual parameters of it's own caller, but also the actual parameters of the above calls.
Don't confuse the two types of macros and conditionals!
| Function | Character macro % | Name macro $ |
| Define Macro | %DEF(<txmacro-name>=<txmacro-body>) | $DEF <macro-name>=<macro-body> |
| Invoke Macro | %<txmacro-name>; | <macro-name> |
| When happens | Preprocessor, during reading the timetable | When a movement is already selected, to evaluate the train or other command parameters |
| Conditional | {<txcondition>?<true-part>?<false-part>} | $IF(<condition>,<true-part>,<false-part>) |