Project members: Enum/Set Item

This member defines a single item (enumerator) within the enum or set member. Item members are represented in Composer by following bricks:

Please note, an item member can exist within an enum or set member only.

Add new enum item

To add a new item into an existing enum member, do following:

First switch to the Composer page for the respective enum member you want to add the new item.

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

Look in the folder for the template named Enum or Set Item.

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

Drop the template within the Composer.

Adding a new item to an enum member.

Add new set item

To add a new item into an existing set member, do following:

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

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

Look in the folder for the template named Enum or Set Item.

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

Drop the template within the Composer.

Adding a new item to a set member.

Please note the limitation of max. 32 item members within a single set member.

Name the item

First ensure, that the enum/set item member is selected.

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

Enter the new name in the Inspector window.

Set an explicit value for the item

During the code generation, Embedded Wizard associates every item with an individual number. In case of items enclosed within an enum member, this process starts with the value 0 for the first item, 1 for the second, 2 for the third and so far. In case of items enclosed within a set member, this process starts with the value 1 for the first item, 2 for the second, 4 for the third and so far - always power of two values. The numbering is performed strictly according to the order in which the particular items are defined within the enum/set member.

If desired, you can override this automatism and specify in its attribute Default another numeric value to associate with a particular item. Please note, the assignment affects the numbering of all consecutive items. For example, if you have specified the value 1369 for an enum item, the next following item will be associated with the value 1370 unless you have assigned another value to this member too.

Duplicate an existing item

You can create any number of copies of an already existing enum item member. In case of items existing in a set member, max. 32 item members are allowed.

First ensure, that the enum/set item member is selected.

Press the keys CtrlC and CtrlV in succession ...

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

Finally rename the just duplicated item member.

Use the item

The name of the item member can be used within Chora expressions to form a literal of the corresponding enumeration data type or set data type.

Delete an item

First ensure, that the enum/set item member is selected.

Press the key DEL or select the menu item EDITDelete.

Attributes of an item

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

Attribute name

Short description

Brick

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

Default

Determines the constant integer value to associate with the enum/set item.

Description

Contains the description for the enum member.

Chora syntax of an item

This section describes the Chora syntax of how enum/set items are stored inside Embedded Wizard project files. The knowledge about the syntax can be helpful when you plan to process the project contents by third party tools. In particular, the general purpose Export and Import functionality introduced in version 14 requires a good understanding of how project members are represented in Chora syntax to correctly interpret the exported members and synthesize the Chora code for members to import. Please note, Embedded Wizard project files (and thus Chora code) are encoded as text in UTF-8 format.

In Chora syntax, the item definition is always introduced with the keyword item, followed by the name of the item and optionally its value. In the case, the value is specified, the name and the value are separated by an assignment operator =. The item definition terminates with ; semicolon sign. Wherever necessary, the tokens are separated by whitespace signs. The value corresponds to the content of the attribute Default.

The definition of an item can be initiated by a comment block providing optional description for the item. The content of this comment corresponds to the value of the item's attribute Description. Furthermore the directive $rect can be specified providing value for the corresponding attribute Brick. The following example demonstrates the described syntax:

// This is an 'item' definition. // // $rect determines the position of the brick inside Composer window. $rect <10,10,210,50> item TheNameOfTheItem = 1024;

Each Chora file (or text exchanged with an external Export and/or Import tool) can be (or even should be) prefixed with $version directive. This directive determines the version number of the included Chora code. For details concerning the syntax of the version please see the chapter $version macro. Furthermore, the code can include a $scope directive followed by a path to a project member acting as the original owner of the corresponding code. That means the members described by the Chora code existed inside the member specified in $scope. In case of an item, $scope would specify the name of the enum or set the item belongs to.