We have introduced a new concept in Classify 2.1: virtual fields. Virtual fields are intended to simplify the display of derived or calculated data and to allow data entry of information that should not be stored in the database.
We have added two new hints pages showing how to use virtual fields to:
- Enter and display a color code, but store a color number.
- Enter and display data from a related file as part of the main file.
In Classify, the data dictionary object realy reflects a specific class of objects from the real world problem domain you are modelling. At times, these class require "properties" that are not stored in the database. A simple example are the properties "Country code" and "Country name". Both are part of the "Address class", but typically you will only store the country code. The country name is than retrieved using some logic (specified in the data dictionary). So far, the UI-designer needed to know that one property was "database related", the other wasn't. After all, an entry statement for country code would involve a file.field reference, the second a function. With virtual fields, we now offer a single consistent interface.
The virtual fields structure allows you to specify additional file.fieldreferences that can be used in the zooms or in the ddo functions using pLocal_Field_Value. You can set up validation, prompt and other field messages for these virtual fields as if they were regular fields.
To specify a set of virtual fields, you must use the following syntax:
Virtual_Structure For Filename Virtual_Field fieldname @_Numeric|@_Date|@_ASCII Field_Length [Decimal_Places] ...... ...... End_Virtual_Structure You can specify multiple virtual fields in a single structure; you can only have a single structure per file.
Once the field is specified, you can set all field messages, as well as field options. There is one new field message that is required for virtual fields, called the display function. You specify this function as follows:
Set pField_Information @_Field_Display_Function Field Filename.Fieldname To Get_Message_Name This should be a function which returns the string representing the value, based on the current buffer content.
The following features are supported for virtual fields:
- All field options (capslock, noenter and such)
- Entering, Exiting, Validate, Prompt, Zoom
- Field Update
- Execution of the pDisplay_Function during display after find
- Get/Set pLocal_Field_Value
Not supported are:
- Save messages
- Delete messages
- Storage allocation if not specified in a zoom
Effectively, this means that if a virtual field is not present in a zoom, it has no effect. So a validation on a virtual field never stop the save if it is not put in a zoom. Whether is should or should not is a difficult point and we might change this based on user input. If you use this feature, please let us know whether you prefer it this way, the other way or don't care.