Go to the first, previous, next, last section, table of contents.


Reversed Equate Calling Mechanism

The # operator is immediately followed by the name of an equate. It results in a call to that equate. Arguments can be passed by pushing values on the stack before calling the function, and any results can be left on the stack before returning where they can subsequently be popped off. The equate need not be defined before it is called.

It is not actually necessary to use the # operator as any variable name will be looked up first as an equate call and if it is not an equate call then as a variable reference. The # operator is still required to flag an equate call from within a text body so it is retained for compatibility.

Equate calls can be given arguments as comma separated items between brackets. Each item must leave a value on the stack. This is identical to just pushing arguments on the stack before calling the function, but is clearer, and makes the separation of each argument more obvious. It also has the advantage that the brackets surround effectively any equate and the same syntax can be used in text bodies (to pass field arguments for example). This can be a useful way of doing some equate processing within the text body itself before calling the function. Note that user defined macros will be expanded within a text body even if within the equate function call. A function can be called with no arguments like f() if preferred. The comma separator is not neccessary, any separator can be used (or even none). For example, the call substr(1,3,"hello") is functionally identical to 1 3 "hello" substr, or substr(1 3 "hello"), or even 1/3"hello"#substr() but is much nicer and will work identically in a text body. Also %%substr(1,3,%%str) will have the user defined macro str expanded before the equate is called.

Since %% will be treated as a user defined macro or equate within a text body the field name operand cannot be used within an equate function call argument, for example, %%substr(1,1,%%field_name) will not work, the processor will interpret %%field_name as a user defined macro or equate. Since this can be a useful way to make general functions the trick is to quote the field name instead, ie. %%substr(1,1,"%field_name") will work. This is slightly different because the data type will end up as EQ_STR rather than EQ_FLD as in the previous equate, but this is usually not a problem.


Go to the first, previous, next, last section, table of contents.