![]() | ![]() | ![]() | ![]() | ![]() |
The subject of macros is reasonably complex (but well worth learning) please ensure you have at least read the macro introduction before reading this section.
In some cases (especially with simple one parameter macros) you may simply wish to supply a value without bothering to name it. For example one way to implement a HTML comment might be:
;--- Define a macro (takes a parameter called "Text") ---- #define COMMENT <!-- {$Text} --> ;--- Use the above macro --- <$COMMENT Text="This will become a html comment">
As you can see from the above we had to use "Text=" even though that is all the parameter could be (at least correctly), lets do this again but this time using a positional parameter:
;--- Define a macro (takes a single positional parameter) ---- #define COMMENT <!-- {$#1} --> ;--- Use the above macro --- <$COMMENT "This will become a html comment">
Now the rules are that positional parameters must start with a double quote (as demonstrated above), a single quote or an equal sign. If unquoted the value is assumed to be a Parameters without a value.
The macro contents refers to the parameters as a '#' followed by a decimal number which indicates it's position (there can be any number of positional parameters).
The reason for the equal sign is that it allows you to quote a string with any quote character (otherwise you wouldn't bother). As an example the above "COMMENT" macro could be called as follows:
;--- Use the above macro --- <$COMMENT "Using double quotes"> <$COMMENT 'Using single quotes'> <$COMMENT =@Using any quotes (can then include '" <-- single and double quotes)@>
![]() | ![]() | ![]() | ![]() | ![]() |