Applies To: |
|
Summary: |
How can I get a drop down combobox on the form for my genie? |
Solution: |
This and many other things can be achieved
by writing your own form file for the genie. Each genie library can
have an associated genie form file written for it (for example
Training.ctm would have Training.frm). The form file should reside
in the same directory as the library (ctm) file. A form definition
for each genie in the associated library can be provided. If one is
not provided then a default form is created as per normal.
FORM "<genie>"[,"<form title>"]; The format of the genie form file follows closely that of the CITECT.FRM file. Each genie form definition is denoted by the keyword FORM. This is followed by the name of the genie as specified in the genie library. For example, if you were writing a form definition for the genie 'Training.Sample', the form file would be "Training.FRM" and the genie name would be "Sample". A title can be provided for the genie form. If none is provided the genie name is used. A record definition must be provided. It consists of a field number, field name and fields size. Each field is linked to the genie by its 'field name'. The field name should match up the substitution string(s) used in the genie. For example if you used %Tag% as a genie substitution string, then Tag would be the field name in the record definition. Any values entered into the Tag field through the form would be expanded out into the genie substitution string %Tag%. The field numbers must be start at 1 and increase conescutively. You can also add extra fields that do not have a corresponding substitution string. Information entered into these fields will be stored but will not be expanded into any other fields. The 'readonly', 'readwrite' keywords have no effect on the form but exists to maintain compatible with the CITECT.FRM structure. If not provided the field defaults to readwrite. A 'list' can be specified for each field. This list appears in a drop down combo box on the form. The 'list form' and 'list field' specify which field of which form to source the contents of the list from. For example if you wanted to list the name from each record in the Variable Tags database you would enter "Variable Tags" and "NAME" for the form and list. A 'list filter' can be specified with the format "<field>=<filtertext>" For example, this can be used to only list tags that are of a specific data type. It is also useful for genies that use structured tag names. <field> is the field name to filter by. This defaults to the field name specified as the 'list field', so <field>= can be omitted. <filtertext> is the text to search for in that field. Only records that have the specified filter text in the specified field will be added to the drop-down list. An * may be used as a wildcard. e.g. Using "*_PV" as the 'list filter' would only add records that end in _PV, and the _PV would be omitted from the name. This would cause tags such as "Loop1_PV" to appear in the list as "Loop1" and tags that don't end in _PV would not be listed. Multiple list filters may be specified between the quotation marks as long as the filters are separated by commas. Any of the forms defined in CITECT.FRM can be used as a 'list form'. If a form from CITECT.FRM is used as 'list form' then 'list field' can be any of the fields from the forms record definition. For example if 'Keyboard Keys' is used as 'list form' then 'NAME', 'CODE', 'ECHO', 'KYBD_TYPE" or 'COMMENT' could be used for 'list field'. The value from the field specified by 'list field' will be taken from each record in the database file (keys.dbf for Keyboard Keys) and added to the list. The keyword 'HELP' can also be specified as the 'list form'. If HELP is specified then the 'list field' can be any of the values from the field 'TYPE' in HELP.DBF (found in the \CITECT\BIN directory). The value from the 'DATA' field for each record whose 'TYPE' matches 'list field' will be used to construct the list. For example if 'BOOLEAN' was specified as the 'list field' then the list would contain 'TRUE' and 'FALSE'. The 'list filter' is not supported by genie form files. It should be noted that any records the user adds to HELP.DBF will be lost the next time they re-install Citect for Windows. The form definition is specified after the record definition. The form definition consists of the keyword NORMAL followed by a string that describes the form. The string describes prompts and fields. A prompt is copied character for character across to the form. Any carriage returns (new lines) are copied across to the form. Fields are indicated by a field number enclosed in brackets. The number of characters separating the brackets (including the field number digits) determines the size of the edit control on the form. The substitution string for this field is determined by the field name of the field with this field number. The prompt does not need to be same as the field name. EXTENDED forms are not supported by genie form files. An example form definition for Sample is shown below. ! Sample genie form ! Insert_Object genie form
For more examples look in the form files in the INCLUDE and EXAMPLE [aka DEMO] projects. See Also: Q1765 Modifying Genie Form Files and Q3643 Creating Custom Dropdown Lists for Genie Forms |
Keywords: |
Related Links
Attachments