Consultor Eletrônico



Kbase 13638: ADM2. Last Item Selected or Deselected in Multiple Select SELECTION LIST
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   15/10/2008
Status: Verified

GOAL:

Which item in a multiple-select selection list has last been selected or deselected.

FACT(s) (Environment):

Progress 8.X
Progress 9.X

FIX:

If your selection list contains the LIST-ITEMS of "Red, Green, Blue", and "Red" has already been selected and you want to be able to tell if the user then adds "Green" to the group of selected items.

This example uses a selection list called SELECT-1 and a fill-in widget called FILL-IN-1. The :SCREEN-VALUE of FILL-IN-1 reports the last selected/deselected item chosen by the user.

The code is:

DEF VAR old-value AS CHAR INITIAL "".   /* holds previous value of
                                          selection list */
DEF VAR i AS INTEGER.

ON VALUE-CHANGED OF select-1 IN FRAME f DO:

 IF NUM-ENTRIES(old-value) < NUM-ENTRIES(select-1:SCREEN-VALUE)
    THEN DO:     /* new value ADDED */

    DO i = 1 TO NUM-ENTRIES(select-1:SCREEN-VALUE):
       IF LOOKUP(ENTRY(i,select-1:SCREEN-VALUE),old-value) = 0
           THEN DO:
              fill-in-1:SCREEN-VALUE =
                           ENTRY(i,select-1:SCREEN-VALUE).
              LEAVE.
       END.
    END.
 END.
 ELSE DO:    /* value TAKEN AWAY */
    DO i = 1 TO NUM-ENTRIES(old-value):
       IF LOOKUP(ENTRY(i,old-value),select-1:SCREEN-VALUE) = 0
           THEN DO:
              fill-in-1:SCREEN-VALUE = ENTRY(i,old-value).
              LEAVE.
        END.
    END.
 END.
 old-value = select-1:SCREEN-VALUE.

END.