Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.
Substitution Examples
Field substitution macros can be used in one of two ways:
Direct Substitution
This form directly substitutes the corresponding value of the element in scope into the output.
Structure: %<macroName>%
Where <macroName> can be any of the macros listed in the Field Substitution Macros tables.
Examples
- %className%
- %opName%
- %attName%
Conditional Substitution
This form of the macro enables alternative substitutions to be made depending on the macro's value.
Structure: %<macroName> ( == "<text>" ) ? <subTrue> ( : <subFalse> ) %
Where:
Examples
- %classAbstract=="T" ? "pure" :""%
- %opStereotype=="operator" ? "operator" :""%
- %paramDefault != "" ? " = " value : ""%
Those three examples output nothing if the condition fails. In this case the False condition can be omitted, resulting in this usage:
- %classAbstract=="T" ? "pure"%
- %opStereotype=="operator" ? "operator"%
- %paramDefault != "" ? " = "value%
The third example of both blocks shows a comparison checking for a non-empty value or existence. This test can also be omitted.
- %paramDefault ? " = " value : ""%
- %paramDefault ? " = " value%
All of the above examples containing paramDefault are equivalent. If the parameter in scope had a default value of 10, the output from each of them would normally be:
= 10
Notes
- In a conditional substitution macro, any white space following <macroName> is ignored; if white space is required in the output, it should be included within the quoted substitution strings
Learn more