PreviousNextIndex

LOOKUP function

Returns an INTEGER value 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
list
character
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 NO-UNDO 
  INITIAL "ME,MA,VT,RI,CT,NH". 
DEFINE VARIABLE state  AS CHARACTER NO-UNDO 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",_Field._Label," ") > 0 
     OR LOOKUP("sales",_Field._Label," ") > 0: 
  DISPLAY _Field._Field-Name _Field._Label. 
END. 

Notes
See also

ENTRY function, ENTRY statement, INDEX function


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex