Project members: Macro

With macros you can define code fragments to use wherever the macro name appears within your project implementation. This is a kind of convenient replacement. Typically macros are used as configuration parameters for components within your application. Macro members are represented in Composer by following bricks:

Macros can be defined within a profile member only. Moreover, only the currently active profile determines the currently available macros. With multiple profiles and the enclosed macros you can manage several device/product variant configurations within one and the same project.

Add new macro

First switch to the Composer page for the respective profile member you want to add the new macro.

Then, in the Gallery window, ensure that the folder Chora is opened.

Look in the folder for the template named Macro.

With the mouse, select the template and drag it into the Composer.

Drop the template within the Composer.

Adding a new macro member.

Name the macro

First ensure, that the macro member is selected.

Press the key F2 or select the menu item EDITRename ....

Enter the new macro name in the Inspector window.

The assigned name identifies uniquely the macro within your project. For example, you can involve the macro name in expressions to conditionally build your application.

Edit the content of the macro

Every macro contains a text or code fragment to incorporate by Chora compiler wherever the corresponding macro name occurs in your project. Do following to specify and modify this content:

First ensure, that the macro member is selected.

In the middle area of the Inspector window locate and adapt the attribute Content.

Duplicate an existing macro

You can create any number of copies of an already existing macro member.

First ensure, that the macro member is selected.

Press the keys CtrlC and CtrlV in succession ...

... or hold the key Ctrl pressed while you drag and drop the selected macro member.

Finally rename the just duplicated macro member.

Macro replacement

You can use the macro as operand within Chora expressions and as initialization value in the most member attributes, as long as the content of the macro is syntactically permitted in the particular context. In order to be distinguished as such, the macro name must be prefixed by a $ (dollar) sign wherever the macro should be evaluated in your project.

Let's assume, your currently selected profile contains a macro named Copyright defined with the content 2016 Company Name. To evaluate this macro within your project use simply the identifier $Copyright. You can, for example, use the macro within a string literal:

var string text = "Copyright $Copyright"; // text = "Copyright 2016 Company Name"

Macros and conditional compilation

Macros can be evaluated in expressions and conditions allowing particular components or code fragments being compiled conditionally depending on the content of the macro.

Delete a macro

First ensure, that the macro member is selected.

Press the key DEL or select the menu item EDITDelete.

Attributes of a macro

The following table shows the complete list of attributes provided by the macro member:

Attribute name

Short description


Determines the position and the size of a macro member brick within the Composer window.


Determines the content of a macro member.


Contains the description for the macro member.