Project members: Set

With the set member you can add a user-defined set data type consisting of uniquely named enumerators. Once defined, this data type can serve in the declaration of any data member within your project. At the runtime, the affected data member can assume any combination of the enumerators listed within the corresponding set member. Set members are represented in Composer by following bricks:

Please note, a set member can exist only within a unit member. Moreover, the maximum number of enumerators within a single set member is strictly limited to 32.

Add new set

First switch to the Composer page for the respective unit member you want to add the new set member.

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

Look in the folder for the template named Set.

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

Drop the template within the Composer.

Adding a new set member.

Name the set

First ensure, that the set member is selected.

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

Enter the new name in the Inspector window.

Set members have a global character - they can be accessed from everywhere within your project. To address a set member, you must always use its full name, which is composed of the unit name, the member is defined inside, and the name of the member itself, both separated by :: (double colon) signs. For example Views::TextAlignment.

Edit the set

Every set member can contain up to 32 enumerator members. To add a new or edit existing enumerators open the set member in a new Composer page:

First ensure, that the set member is selected.

Press the key ENTER ...

... or double click on the set member with the mouse.

Please note, newly added set members contain already few dummy enumerators called per default FirstItem, SecondItem and so far. Feel free to rename or delete them.

Duplicate an existing set

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

First ensure, that the set member is selected.

Press the keys CtrlC and CtrlV in succession ...

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

Finally rename the just duplicated set member.

You can also Drag & Drop a set member from the Browser into the Composer window and create so a duplicate of the affected member:

First switch to the Composer page for the respective unit member, where you want to add the duplicate of the set.

Then ensure that the Browser window is visible.

Within the Browser window locate the desired set member. This can be done easily with Browser's own filter function.

Select this set member in the Browser window.

Drag and drop the selected set member into the Composer:

Duplicating a set by simply Drag & Drop it between the Browser and Composer windows

Finally rename the just duplicated set member.

Use the set member in data member declarations

Every set member represents an individual user defined set data type, you can use in the declaration of variables, properties, arrays, local variables, local arrays as well as in parameter and return type declaration of a method. The set data type corresponds to the full name of the set member, composed of the unit name, the member is defined inside, and the name of the member itself, both separated by :: (double colon) signs. For example:

// Declare a local variable of the 'Views::TextAlignment' set type
var Views::TextAlignment alignment;

Use the set member in expressions

The name of the set member can be used within Chora expressions to form a literal of the corresponding set data type. The literal is composed of the corresponding data type name and a list of , (comma) separated enumerator names enclosed between a pair of [...] (square brackets). For example:

// Declare a local variable of the 'Views::TextAlignment' set type
var Views::TextAlignment alignment = ...;

// Add the both enumerators 'AlignHorzLeft' and 'AlignVertTop' to the current
// value of the variable 'alignment'.
alignment = alignment + Views::TextAlignment[ AlignHorzLeft, AlignVertTop ];

Control the code generation

With the attribute Generator you can selectively control, whether the set member should be taken in account during the code generation or not. Configuring this attribute with the value false will exclude the member from your project unless the member name is explicitly involved within a Chora expression or data member declaration.

Delete a set

First ensure, that the set member is selected.

Press the key DEL or select the menu item EDITDelete.

Attributes of a set

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

Attribute name

Short description

Brick

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

Description

Contains the description for the set member.

Generator

Controls the code generation for the affected set member.