Consultor Eletrônico



Kbase P14378: How to check a list-pair-items for a particular value
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   1/29/2003
Status: Unverified

GOAL:

How to check a list-pair-items for a particular value

FIX:

LIST-ITEM-PAIRS is a comma separated list of "Label,Value" combination for a list of items in a combo-box or Selection-List.
You cannot use LOOKUP function like LOOKUP( cValue, lstItems:LIST-ITEM-PAIRS )
because it can return the label of the item but not the value.
This code can be use instead:
DEF VAR vi AS INTEGER.
DEF VAR cValue as CHARACTER INIT '3' . /* want to check this value */
/* Let's say LIST-ITEM-PAIRS is "Item 1,1,Item 2,2,Item 3,3,Item 4,4" */
DO vi = 1 TO NUM-ENTRIES( lstItems:LIST-ITEM-PAIRS ) / 2 :
IF ENTRY( 2 * vi, lstItems:LIST-ITEM-PAIRS ) = cValue THEN
/* I found my value here*/ .
ELSE
/* maybe next item */ .
END.