Fields - name


field_id, [”heading”], type & size [[dim1 [, dim2 [, dim3 [, dim4]]]]] \
[/logical] [,”format” [, flags [, “validation”]]]

The name of a field is also known as the field’s identifier. It is the name that is used to refer to the field in a program, and will usually give some indication as to the nature of the data the field will contain.

The same naming rules apply to fields defined with all the following methods:

1

Fields in Sculptor keyed files (created with the ddeditor program)

2

Temporary fields (declared in a program’s code with the !temp or !auto declaration)

3

Fields in temporary record layouts (declared in a program’s code with the !record declaration)

The usual identifier naming rules apply to field names. Note also that data dictionary field names cannot also be used as secondary index names for the same file.


EXAMPLES

!temp DOB,"Date of Birth",i4/dn
!auto GrandTotal,,i4 = GrandTotal + tb_total

Duplication of field names

Keyed files

Every field name in a keyed file must be unique within that file. However, the same name may be used in two or more different data dictionaries without conflict arising in a program that uses them both. This is because all files declared in a program are assigned a unique file_id, which can be used as a prefix to the field name to construct a unique identifier.

Temporary fields

Fields declared with !temp must be unique within a program unless declared as local variables within a user-defined function, in which case duplication is permitted. Global temporary fields are automatically assigned to the record_id tmp, which may be used as the prefix. Therefore the global temporary field “Surname” may also be referenced as “tmp.Surname”. Inclusion of the prefix is recommended.

Automatic temporary fields

Fields declared with !auto are automatically assigned to the record_id auto, which may be used as the prefix. Therefore no field name may be used for more than one !auto field, though the same name may be used for a !temp field and a !auto field.

Temporary record layouts

Every field name within a !record layout must be unique to that layout. Names may be duplicated between layouts, using the record_id to distinguish them. For example:

!record Sales {
     Stock,,i2
     Code,,a3
}

!record Purchases {
     Stock,,i2
     Code,,a3
}

These four fields are subsequently referred to as:

Sales.Stock
Sales.Code
Purchases.Stock
Purchases.Code

Global assignment between identically named fields

The current contents of a file buffer or temporary record structure may be copied to another with a single command by the use of identical field names in the source and destination objects. See record assignment.


RELATED TOPICS

Data fields