Zum Hauptinhalt springen

Macro definition

XML
<macro var="var">
ixml
</macro>

The <macro /> construct defines an open subroutine as a code sequence that can be expanded with subsequent EXPAND statements.

Macro expansion allows for code reuse with minimal computational overhead compared to function invocation.

A macro can be coded so that it may expand itself recursively. This technique allows direct implementation of functions defined by mathematical induction and recursive divide and conquer algorithms.

Attention:

The macro remains within the current context when being expanded.

Attributes

NameTypeDescriptionDefined By
varvarVariable name macro

Results

BindingTypePredicate
varmacrono-result-propagation

Examples

Basic macro expansion

XML
<macro var="outputName">
<output>$name</output>
</macro>

<set var="name">iXML</set>
<expand macro="outputName"/>

<!-- iXML -->

Iterating macro expansion

XML
<macro var="outputName">
<output>$name&n;</output>
</macro>

<array var="names">
<item>Bill Gates</item>
<item>Steve Jobs</item>
</array>

<foreach var="names" var_value="name">
<expand macro="outputName"/>
</foreach>

<!--
Bill Gates
Steve Jobs
-->