lookup()

Function group Execute on client Platform(s)
Lookup NO All

Syntax

lookup([refname,]searchvalue[,fieldnumber])

Description

Returns a field value from another data file refname (opened as a lookup file) using a searchvalue.

The fieldnumber argument specifies the particular field in the lookup file to be returned by the function. Each lookup file is opened using the Open lookup file command at which time a reference label is assigned to that lookup.

If you omit the third argument, the value of the second field is returned by default. If one argument is given, the default lookup file is used, that is, the lookup file which was opened without a reference label, or the first lookup file opened if all have labels.

If no exact match is found, an empty value is returned. All field types are returned, including pictures and long text.

Example

Open lookup file {City/Cities.df1/FCITY/1}
# Reference name is City, file class FCITY

OK message {CNAME is [lookup('City','FOS',2)]}
# Uses first field in FCITY as the index