FIELD Verb

Syntax

FIELD strname,str{,[int]}=expr{,ERR=lineref}


Description

For BBj-specific documentation, see Field Verb - BBj.

The FIELD verb allows assignment of data into fields of a string template.

Parameter

Description

strname

Simple string variable dimensioned with a template. An !ERROR=47 is generated when str does not appear in strname.

str

Field name within the template.

int

Index of the array specified by str.

ERR=lineref

Branch to be taken if an error occurs during execution.

For additional information, see String Templates in the User's Reference Guide. Though hard-coded field names may be used, the FIELD verb allows dynamic run-time access to fields. For example, the following statement is hard coded:

LET A.FIELD$="data"

The same thing can be done with the FIELD statement:

FIELD A$,"FIELD"="data"

The advantage of the FIELD statement is that it does not have to be hard coded. The following example does the same thing:

LET B$="FIELD"
FIELD A$,B$="data"

This can be used for database and report generator applications that may access data dictionaries at run time.

Numeric data may also be assigned:

FIELD A$,"TOTAL"=X*4.5

The use of a numeric expression instead of a string expression generates an error, if the field called "TOTAL" was not defined as numeric.

For repeating fields, a subscript could be provided:

FIELD A$,"RATE",[10]=2.5

The brackets are required to avoid syntax ambiguity. The value, 10, indicates the tenth value of the field called RATE and assumes that RATE was defined as a repeating field.

See Also

Verbs - Alphabetical Listing