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 .
★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 .
Attributes of a set
The following table shows the complete list of attributes provided by the set member:
Attribute name |
Short description |
---|---|
Determines the position and the size of a set member brick within the Composer window. |
|
Contains the description for the set member. |
|
Controls the code generation for the affected set member. |
Chora syntax of a set
This section describes the Chora syntax of how sets 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, set definition is always introduced with the keyword set, followed by the name of the set and a list of set items enclosed between a pair of curly braces {..}. Concerning the syntax of an item, please see Chora syntax of an item.
The definition of the set can be initiated by a comment block providing optional description for the set. The content of this comment corresponds to the value of the set's attribute Description. Furthermore the directives $rect and $output can be specified providing values for the corresponding attributes Brick and Generator. The following example demonstrates the described syntax:
// This is a 'set' definition containing three items. // // $rect determines the position of the brick inside Composer window. // $output enforces this member to be taken in account during code \ // generation. $rect <10,10,210,50> $output true set NameOfTheSet { $rect <10,10,210,50> item FirstItem; $rect <220,10,420,50> item SecondItem = 16; $rect <430,10,630,50> item ThirdItem; }
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 a set, $scope would specify the name of the unit the set belongs to.