Progress
Language Reference


LOOKUP Function

Interfaces
OS
SpeedScript
All
All
Yes

Returns an integer giving the position of an expression in a list. Returns a 0 if the expression is not in the list.

SYNTAX

LOOKUP ( expression , list [ , character ] ) 

expression

A constant, field name, variable name, or expression that results in a character value that you want to look up within a list of character expressions. If the value of expression is unknown (?), the result of the LOOKUP function is unknown.

list

A list of character expressions that contains the expression you name with the expression argument. Separate each entry in list with a delimiter. The default is a comma. If list is the unknown value (?), the result of LOOKUP is the unknown value.

character

A delimiter you define for the list. The default is a comma. This allows functions to operate on non-comma-separated lists.

EXAMPLES

This procedure prompts the user for a New England state. The LOOKUP function tests the value against the list of states stored in the stlist variable. If there is no match (the result is 0), the procedure displays a message. Otherwise, the procedure prompts the user for another New England state.

r-lookup.p
DEFINE VARIABLE stlist AS CHARACTER
  INITIAL "ME,MA,VT,RI,CT,NH".
DEFINE VARIABLE state AS CHARACTER FORMAT "x(2)".

REPEAT:
  SET state LABEL
    "Enter a New England state, 2 characters".
  IF LOOKUP(state, stlist) = 0
  THEN MESSAGE "This is not a New England state".
END. 

The following example uses a different delimiter, which list all fields that have “sls” or “sales” as words in their standard Dictionary labels.

r-look2.p
FOR EACH _Field
  WHERE LOOKUP("sls",_Label," ") > 0
  OR LOOKUP("sales",_Label," ") > 0:

  DISPLAY _Field-name _Label.
END. 

NOTES

SEE ALSO

ENTRY Function, ENTRY Statement, INDEX Function


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095