Function Macros

Function macros are a convenient way of manipulating and formatting various element data. 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: %CONVERT_SCOPE(opScope)%

The available function macros are described below. Parameters are denoted by angle brackets, as in: FUNCTION_NAME(<param>).

CONVERT_SCOPE(<umlScope>):

For use with supported languages, to convert <umlScope> to the appropriate scope keyword for the language being generated. The following table shows the conversion of <umlScope> with respect to the given language.

Language

Package

Public

Private

Protected

C++

public

public

private

protected

 

C#

internal

public

private

protected

 

Delphi

protected

public

private

protected

 

Java

 

public

private

protected

 

PHP

public

public

private

protected

 

VB

Protected

Public

Private

Protected

 

VB .Net

Friend

Public

Private

Protected

 

COLLECTION_CLASS(<language>):

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

CSTYLE_COMMENT(<wrap_length>):

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.

DELPHI_COMMENT(<wrap_length>):

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

EXEC_ADD_IN(<addin_name>, <function_name>, <prm_1>, ..., <prm_n>):

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.

GET_ALIGNMENT():

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

JAVADOC_COMMENT(<wrap_length>):

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

LEFT(<src>, <count>):

The first <count> characters of <src>.

LENGTH(<src>):

Length of <src>. Returns a string.

MID(<src>, <count>)
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> 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 below:

 

%PI=" "%

%classAbstract ? "abstract"%

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

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

%classTag:"macro"%

%endIf%

class

%className%
 
 

For more details, see the description of PI.

PROCESS_END_OBJECT(<template_name>):

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>.

RESOLVE_OP_NAME():

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

RESOLVE_QUALIFIED_TYPE()
RESOLVE_QUALIFIED_TYPE(<separator>)
RESOLVE_QUALIFIED_TYPE(<separator>, <default>):

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>.

TO_LOWER(<string>):

Converts <string> to lower case.

TO_UPPER(<string>):

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>.

VB_COMMENT(<wrap_length>):

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.

XML_COMMENT(<wrap_length>):

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