Working with Macros

 

 

 

Macros

 

pasUnity supports a custom macro language that can be used when constructing mapping to assist in the conversion of data from the source to the destination.  The macro language is both flexible and powerful allowing for the extraction of values from the available data, external conditions, and additional files.  With the ability to contain nested macros and perform conditional processing, pasUnity's macro language facilitates easy translation of data from source to destination.

 

Macro Elements

Macros are specified by being wrapped in angle brackets < >. Macros that do not start and stop with angle brackets will not be properly parsed and will cause errors.  Most macros consist of multiple arguments.  These arguments are separated with a pipe character |. Each macro will contain a different number of arguments.  Some of the arguments may be required while others may be optional. If an opening bracket, closing bracket, or pipe character needs to be part of one of the arguments in the macro a percent sign % can be used as an escape character which will prevent the very next character from being interpreted.

Example: <Lower|This contains %<brackets%>>

Returns "this contains <brackets>"

NOTE: The escape character is macro language and will only be parsed inside of a macro statement.

 

Nested Macros

Within pasUnity, macros have the ability to contain other macros.  This is referred to as nesting and allows for added flexibility when dealing with macros such as If or Error.  There is no limit to how many macros can be nested.  All of the macros that are available can be nested inside any other macro.

 

Error Handling

With the added flexibility of the macro language, there opens up the possibility that an error may happen when parsing due to malformed macros.  pasUnity exposes 4 different ways of dealing with these errors. The first is to display a message box detailing the error encountered within the macro.  This is useful and recommended when processing data with pasUnity manually. The second is to preserve the unparsed macro in the resulting string.  The third is to insert nothing into the string.  The fourth is to insert the reason for failure within the string.  The last three options are recommended when using pasUnity in an automated scenario.

 

Case Sensitivity

The names of the macros themselves are not case sensitive, meaning that Upper is the same as UPPER. Arguments for the macros may or may not be case sensitive, so please consult the documentation for the specific macro that is being used.

 


Copyright © 2024 pasUNITY, Inc.

 

Send comments on this topic.