Function Macros

Function macros are a convenient way of manipulating and formatting various element data items. Each function macro returns a result string. There are two primary ways to use the results of function macros:

  • Direct substitution of the returned string into the output, such as: %TO_LOWER(attName)%
  • Storing the returned string as part of a variable definition such as: $name = %TO_LOWER(attName)%

Function macros can take parameters, which can be passed to the macros as:

  • String literals, enclosed within double quotation marks
  • Direct substitution macros without the enclosing percent signs
  • Variable references
  • Numeric literals

Multiple parameters are passed using a comma-separated list.

Function macros are named according to the All-Caps style, as in:


The available function macros are described here. Parameters are denoted by square brackets, as in:



For use with supported languages, to convert [umlScope] to the appropriate scope keyword for the language being generated. This table shows the conversion of [umlScope] with respect to the given language.




Package ==> public

Public ==> public

Private ==> private

Protected ==> protected


Package ==> internal

Public ==> public

Private ==> private

Protected ==> protected


Package ==> protected

Public ==> public

Private ==> private

Protected ==> protected


Package ==> {blank}

Public ==> public

Private ==> private

Protected ==> protected


Package ==> public

Public ==> public

Private ==> private

Protected ==> protected


Package ==> Protected

Public ==> Public

Private ==> Private

Protected ==> Protected

VB .Net

Package ==> Friend

Public ==> Public

Private ==> Private

Protected ==> Protected


Gives the appropriate collection Class for the language specified for the current linked attribute.


Converts the notes for the element currently in scope to plain C-style comments, using /* and */.

DELPHI_PROPERTIES([scope], [separator], [indent])

Generates a Delphi property.


Converts the notes for the element currently in scope to Delphi comments.

EXEC_ADD_IN(, [function_name], , ..., )

Invokes an Enterprise Architect Add-In function, which can return a result string.

[addin_name] and [function_name] specify the names of the Add-In and function to be invoked.

Parameters to the Add-In function can be specified via parameters [prm_1] to [prm_n].

     $result = %EXEC_ADD_IN("MyAddin", "ProcessOperation", classGUID, opGUID)%

Any function that is to be called by the EXEC_ADD_IN macro must have two parameters: an EA.Repository object, and a Variant array that contains any additional parameters from the EXEC_ADD_IN call. Return type should be Variant.

     Public Function ProcessOperation(Repository As EA.Repository, args As Variant) As Variant

FIND([src], [subString])

Position of the first instance of [subString] in [src]; -1 if none.


Returns a string where all of the text on the current line of output is converted into spaces and tabs.


Converts the notes for the element currently in scope to javadoc -style comments.

LEFT([src], [count])

The first [count] characters of [src].


Length of [src]. Returns a string.

MID([src], [start]) MID([src], [start], [count])

Substring of [src] starting at [start] and including [count] characters. Where [count] is omitted the rest of the string is included.

PI([option], [value], {[option], [value]})

Sets the PI for the current template to [value]. Valid values for [value] are:

  • "\n"
  • "\t "
  • “ “
  • “”

<option> controls when the new PI takes effect. Valid values for <option> are:

  • I, Immediate: the new PI is generated before the next non-empty template line
  • N, Next: the new PI is generated after the next non-empty template line

Multiple pairs of options are allowed in one call. An example of the situation where this would used is where one keyword is always on a new line, as illustrated here:

%PI=" "%

%classAbstract ? "abstract"%

%if classTag:"macro" != ""%

%PI("I", "\n", "N", " ")%





For more details, see the description of PI.


Enables the Classes that are one Class further away from the base Class, to be transformed into objects (such as attributes, operations, Packages, parameters and columns) of the base Class. [template_name] refers to the working template that temporarily stores the data.

REMOVE_DUPLICATES([source], [separator])

Where [source] is a [separator] separated list; this removes any duplicate or empty strings.

REPLACE([string], [old], [new])

Replaces all occurrences of [old] with [new] in the given string <string>.


Resolves clashes in interface names where two method-from interfaces have the same name.


Generates a qualified type for the current attribute, linked attribute, linked parent, operation, or parameter. Enables the specification of a separator other than. and a default value for when some value is required.

RIGHT([src], [count])

The last [count] characters of [src].


Converts [string] to lower case.


Converts [string] to upper case.

TRIM([string]) TRIM([string], [trimChars])

Removes trailing and leading white spaces from [string]. If [trimChars] is specified, all leading and trailing characters in the set of <trimChars> are removed.

TRIM_LEFT([string]) TRIM_LEFT([string], [trimChars])

Removes the specified leading characters from <string>.

TRIM_RIGHT([string]) TRIM_RIGHT([string], [trimChars])

Removes the specified trailing characters from <string>.


Converts the notes for the element currently in scope to Visual Basic style comments.

WRAP_COMMENT([comment], [wrap_length], [indent], [start_string])

Wraps the text [comment] at width [wrap_length] putting [indent] and [start_string] at the beginning of each line.

     $behavior = %WRAP_COMMENT(opBehavior, "40", "  ", "//")%

<wrap_length> must still be passed as a string, even though WRAP_COMMENT treats this parameter as an integer.

WRAP_LINES([text], [wrap_length], [start_string] {, [end_string] })

Wraps [text] as designated to be [wrap_length], adding [start_string] to the beginning of every line and [end_string] to the end of the line if it is specified.


Converts the notes for the element currently in scope to XML-style comments.