Topic group Related topics Example
Defines the list of fields a table appears to have.
SET FIELDS TO
[<field list> | ALL [LIKE <skeleton 1>] [EXCEPT <skeleton 2>]]
SET FIELDS on | OFF
<field list> | ALL [LIKE <skeleton 1> | EXCEPT <skeleton 2> ]
Adds the specified fields to the list of fields the table appears to have. The fields list may include fields from tables open in all work areas and may also include read-only calculated fields. The following table provides a description of SET FIELDS TO options:
Adds all fields in the current work area to the field list
LIKE <skeleton 1>
Adds all fields in the current work area whose names match <skeleton 1> to the field list
EXCEPT <skeleton 2>
Adds all fields in the current work area except those whose names match <skeleton 2> to the field list
LIKE <skeleton 1>
Adds all fields in the current work area whose names are like <skeleton 1> except those whose names match <skeleton 2> to the field list
When there is no field list, or SET FIELDS is OFF, operations in a work area that use all fields (by default) use all the fields in the currently selected table. For example, if you LIST a Customer table with 10 fields and 500 records, those 10 fields are displayed.
A field list overrides this default behavior, making the table appear to have the fields you specify. This is usually done to either:
Restrict the fields to certain fields in the table. For example, you can make the Customer table appear to have only a customer ID and name, hiding the other 8 fields.
Include fields in other related tables. For example, you could set a relation to a table of sales people, and make the Customer table appear to have the customer ID, customer name, and the name of their account representative.
When a field list is active, it is the field list for all work areas in the workset. Because the fields in a field list always contain the full alias and field name, the fields in the field list will always be used, even if those fields are in another, unrelated work area. For example, suppose you create a field list with fields from the Customer table, and then select the Vendor, which has 90 records and is not related into the Customer table. If you then issue LIST, you will see 90 records, because the LIST command works on the current work area, but you will see the fields from the Customer tableóthe fields from the same record repeated 90 times, because the two tables are not related, and those are the values of the named fields for each record in the Vendor table.
Therefore, when you create a field list, it is usually used only for the work area in which it is created. If the field list contains fields from other work areas, some way of synchronizing the movement of the record pointers in those work areas, usually with SET RELATION, is required.
If there is no field list, SET FIELDS creates the specified field list and activates it. If there is a field list, whether itís active or not, SET FIELDS adds the specified fields to the field list, and activates it. Fields in other work areas that are added to the field list may be referred to by their field name only, without using an alias; those fields now appear to be fields in the current work area. The alias is still allowed, and is necessary if you have two fields with the same name from different tables in the field list.
A field may be added to the field list more than once, although this is not recommended. For example, if you execute SET FIELDS TO ALL twice, you will see all the fields in the current table twice. Be sure to use CLEAR FIELDS before issuing SET FIELDS if your intent is to create a new field list, not add to an existing field list. To specify a field in other work areas, prefix the field name with the alias name and alias operator (that is, alias->field).
You can temporarily disable the field list with SET FIELDS OFF. To reactivate the field list, use SET FIELDS ON. Adding fields with SET FIELDS always reactivates the field list. If you SET FIELDS ON without using the SET FIELDS TO <field list> command, no fields are accessible. SET FIELDS TO with no fields has the same effect as CLEAR FIELDS, deactivating and clearing the field list.
Some commands have a FIELDS option, or some way of specifying fields. You may further restrict the fields used with this option, but you cannot reference fields that have been hidden because they have not been included with SET FIELDS.
When a field list is active, fields that are not on the field list cannot be used in expressions. However, some commands ignore the field list, including:
INDEX and index expressions
The fields list specified with SET FIELDS TO can include both table field names and calculated fields. The /R option provides a setting to specify read-only access to table fields, for example:
To specify a calculated field, you can specify any valid expression. For example,
gross_pay = salary * hours
No direct equivalent. When accessing the fields array, you may include program logic to include or exclude specific fields.