Declaring a temporary field¶
!temp |
Declare a temporary field |
Contents
Syntax¶
!temp field_id, [”heading”], type & size [[dim1 [,dim2 [,dim3 [,dim4]]]]] [/logical] [, “format” [,flags [, “validation”]]] [ = expression]
Declare a temporary field for use within the program. Once defined, a temporary field may be treated in the program in the same way as a field from a Sculptor keyed file.
The !temp declaration is composed as follows:
field_id |
The identifier name by which the temporary field will be known. See below. |
heading |
The default heading to be used if the temporary field is displayed on the screen or printed. Must be enclosed in quotes. Two consecutive commas at this point cause the field_id to be used as the heading. |
type & size |
Any valid Sculptor data type. Additional types available for temporary fields are p (pointer) and o (object). |
dim |
The number of subscripts the field is to have, in up to four dimensions. The subscripts are enclosed in square brackets, with each dimension separated by commas. |
logical |
Defines the field as a special logical type, such as date or time. |
format |
A template controlling the specific format to be used for input, display and printing of this field. The format must be enclosed in quotes. Two consecutive commas indicate that no special format is required, in which case the default for the field type and size will be used. |
flags |
One or more flag characters specifying more general formatting operations. Flag characters are not enclosed in quotes. Two consecutive commas indicate that no flags are required. |
validation |
A validation list indicating the acceptable values for input into the field. |
expression |
Initial value. See The expression clause. |
See Structure of a data field for more information.
Normally the scope of a temporary field is the entire program. Note, however, that a local temporary field may be defined within a !function or !record construct. In this case, the scope of the field is that construct only.
Naming temporary fields¶
Temporary fields must be assigned a valid identifier name.
The identifier must usually be unique within the program; however, two or more identically named temporary fields may exist, provided that not more than one of them is declared in the main program code, or within the same function or report.
Temporary fields declared as part of a !record structure may have the same name as temporary fields declared with !temp, or as fields in other structures. This is because such fields are subsequently referenced by a composite name made up of the record identifier as well as their own name: (record_id.field_id) and are therefore always unique.
The default temporary field group ‘tmp’¶
All global temporary fields in a program are allocated to the default group tmp. They may be referenced with or without the group name. So the field declared as:
!temp address,,a30
can be referred to either as “address” or as “tmp.address”. The latter is recommended as this avoids possible conflicts arising if new files are added to the program.
Temporary fields not included in the tmp group are:
1 |
Temporary fields which form part of a !record structure. |
2 |
Temporary fields declared locally within a user function (!function). |
The command clear tmp may be used to clear all fields in the group tmp.
Note that the clear command with no arguments does not clear the values of temporary fields.
The expression clause¶
The optional expression clause may be used to assign an initial value to a temporary field. The value is assigned once and once only as part of the initialisation procedure. The field is subsequently treated exactly as any other temporary field; its value may be changed by direct assignment. If the field is subscripted, the value of expression is assigned to the first element only. If expression fails a validation test, either by resulting in a value inappropriate to the temporary field’s type & size, or by failing to fall within the values defined in its validation, the appropriate null value (0 or an empty string) is assigned.
If the expression is a date, it must be enclosed in quotes, e.g. “24/3/2005”
Note
Since Sculptor version 6.4.0 the expression for an array field can be a literal array definition, like:
!temp testIntArr,,i4[8] = [10, 20, 30, 40, 50, 60, 70, 80]
Pointer type temporary fields¶
The special field type p indicates that the field is an object pointer. This field type is only valid for temporary fields. See Pointer fields.
Object type temporary fields¶
The special field type o is a pointer type, taking the type, size and dimensions of the object it refers to, and so is declared without these properties:
!temp field_id,,o
Object type fields are used to store references to objects, returned by the OLE object functions create_object(), get_object() and load_picture(). See Object pointer fields.
NOTES
No temporary field may exceed 65,535 bytes in size.
For maximum portability, especially to DOS systems, temporary fields should be grouped into !record structures such that no single !record exceeds 65,535 bytes. For this reason, !temp fields which define large arrays are best placed in a !record of their own, rather than in the default record tmp.
EXAMPLES
!temp Name,"NAME",a30[15],"u",u
!temp Integer,,i1[10,10], "##",,"1-49"
!temp Time,"TIME",i2/ts,"hh:mm"
!temp DateField,"DATE",i4/dn = "14/2/2003"
!temp MatchTraps,,a200,,v
RELATED TOPICS |