Macro Command Help

FIELD

 

Macro Command Name

Menu Path

Link to Command Table

FIELD

Access via macro or menu only

Click here

Introduction

Detects the existence of a database file and sets up substitution variables to the values of fields in the file, for a particular record. Default values of fields may also be found.

How to use

The format is:-

!FIELD <var1>=<filename>,<var2>=N,<var3>=<field1>,<var4>..

where:

  

<var1>  

is a substitution variable.

  

<filename>  

is the name of the database file.

  

N  

is the number of the record in the database file.

  

<var2>  

is a second substitution variable.

  

<var3>  

is a third substitution variable.

  

and so on.

 

 

The command may extend over more than one line by ending the previous line with a comma.

The variable <var1> will be set to 0 if the file does not exist, or there is a file read error, or the file has no read access, or if any of the specified fields do not exist. If the file exists, the Data Definition can be read, read permission is granted, and all fields exist, <var1> becomes 1.

The variable <var2> should be set to the value of the particular record required. A value of 0 will give field default values, while + or a value greater than the maximum number of records in the file will give the last record in the file.

<var2>  

is set to the maximum number of records in the file or 0 if the database file does not exist.

<var3>  

is set to the value of <field1> in record N.

<var4>  

is set to the value of <field2> in record N.

and so on.

 


Notes

A message will be sent to the display if the file does not exist, or read permission is denied, or there is a read error or any of the specified fields do not exist.

General Format:

!field <var1>=<file>,<var2>=<record>, <varA>= <fieldA>,<varB>=<fieldB>, ...

Supplied Values:

The values "<file>,<record>,<fieldA>"  may be supplied either as constants or substitution variables. These values specify what is to be read by FIELD.

<file>  

Nominates the database file to read.

<record>  

Specifies the index of the record to read from the start of <file>. '0' will return the default values from the data definition. '+' or >maximum records will return the values from the last record in <file>.

<fieldA>  

Nominates the name of the field to examine. Substitution variables will be set based on the value found in <fieldA>, and the state of the file <file>.

Returned Values:

The values "<var1>,<var2>,<varA>" must be supplied as substitution variables, and are SET to special values on completion of the FIELD command.

<var1>

 Is set to 1 if <file> exists, 0 = does not exist.

<var2>

Is set to the total number of records in <file>. If <file> does not exist, <var2> is set to 0.

<varA>

 Is set to the value of <fieldA> in record number <record> from the start of <file>. If <file> does not exist, or <fieldA> does not exist in <file>, then <varA> is unchanged.

 

Multiple pairs in the form <varA>=<fieldA>, <varB>=<fieldB>, ... can be supplied to extract more than one value in a single field call. The list may be extended onto as many lines as necessary; continuation is implied by ending the previous line with a comma.


Example

Example 1

Find the hole name of the 1000th sample in an assay file. The variable "$hole#" is used to return this value; "$exists#" will be set to 1 if the file ASSAYS is found; "$records#" will be set to the total number of samples in the file.

 !FIELD $exists#=ASSAYS,$records#=1000,$hole#=BHID

Example 2

Extract the data area limits (mm) from a plot file. These values are usually stored as implicit fields in the plot file header.

!FIELD $found#=PLOT.P,$recs#=0,$xorig#=XORIG, $yorig#=YORIG, $xrt#=XRT, $ytp#=YTP


Error and Warning Messages

Message

Description

Solution

>>> !FIELD:  ILLEGAL FORMAT <<<

>>> ERR 90 <<< (      0) IN SOFFIE

<listing of command line>

The command is malformed.  Fatal; the macro or menu is cancelled.

Check the command syntax.