|
Forms | LOOKUP |
LOOKUP
uses another screen to locate a record. If the
specified record is not found, an error message is issued. The
LOOKUP
can reference or retrieve data from the specified
record. See syntax.
The stand-alone LOOKUP
command is very similar to the
LOOKUP
clause of the FIELD
command.
LOOKUP
can perform a number of functions:
USING
or VIA
clauses. If keys are not specified, the first record of this type is used.
USING
or VIA
clauses.
LOOKUP
command must specify the ON screen_name
clause. Available clauses are:LOOKUP {lookup expression} [NOT]ON screen_name[ /database.record | /tabfile.table] BACKWARDS | FORWARDS n ERROR nnn 'message' IF ( expression ) IN expression LOCK locktype REPORT 'message' RETURNING expression, ... TO variable, ... USING caseid [ * ] | [ key, ... ] VIA * | key, ...
lookup expression
IN
clause. If a lookup expression
is not specified, do not specify an IN
expression.[NOT]ON
LOOKUP
. ON
or
NOTON
is the only required clause. ON
checks that a record matching the search criteria exist.
NOTON
returns an error message if a record matching the search
criteria exists.
screen_name
BACKWARDS n|
FORWARDS n
USING
or
VIA
specifies a partial key, the direction of search can be
set. The default direction is FORWARD
. When a number is
specified, the nth record matching the search criteria is selected.
ERROR
IF
LOOKUP
command is executed. If the expression is true, the
LOOKUP
is performed. If it is false, the
LOOKUP
is not performed.
IN
USING
or
VIA
clause specifies a complete key, that record is tested.
If the USING
or VIA
clause, specifies a
partial key, the defined set of records is searched for a match.
LOCK
REPORT
RETURNING
to
copy the values to fields that are displayed on this screen.
RETURNING
LOOKUP
record that are transferred to the fields in the
TO
list. The RETURNING
and the
TO
list are positionally matched. The first variable in the
RETURNING
list is moved to the first variable in the
TO
list, the second to the second and so on. Variables
referenced in the RETURNING
list must be available to the
LOOKUP
record; variables in the TO
list must
be available to the current record.USING
LOOKUP
uses a different case.
Specify the case id value, optionally followed by other key field values.
Specify an asterisk (*) to indicate that the key fields of the current screen
are to be used. USING
specifies a different case and thus
cannot be used for databases without case structures and cannot be used in
conjunction with the VIA
clause.VIA
LOOKUP
within this
case, to another record on a caseless database or to a table screen. Specify
values for the key fields. Specify an asterisk (*) to indicate that the key
fields of the current screen are to be used. If the key is not unique for one
record, but defines a set of records, the first record in the set is used.
(This can be changed with the FORWARD
and
BACKWARDS
clauses).
Example: This returns the location status to a temporary field
XSTATUS
(which has been DECLARED
on the
FORM
command) and then displays the result.
LOOKUP ON LOCREC USING -1, LOCATION - RETURNING STATUS to XSTATUS - ERROR 59 'Invalid Location Code - Please Re-enter' FIELD XSTATUS DISPLAY 'Location Status'