Kbase 16393: ADM2. How to De-select Items from Multiple Selection List
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  15/10/2008 |
|
Status: Verified
GOAL:
Sample code the de-selects an item from the screen value of a SELECTION-LIST with the MULTIPLE attribute set.
FACT(s) (Environment):
Progress 8.x
Progress 9.x
Progress ADM2
CAUSE:
The MULTIPLE attribute allows the user to select more than a single value from the selection list.
You can select multiple values that your application might need to process individually. As each is processed, you might want to display the remaining items selected so the user can see which have or haven't been processed.
The multiple values you select are stored in the selection list's SCREEN-VALUE as a comma-delimited list of character strings (such as itemtwo, itemfour). You must manipulate this list and update the SCREEN-VALUE as you remove each item you select.
NOTE: This has no effect on the list of valid choices you defined for the the selection-list. The SCREEN-VALUE is only related to the items selected by the user (the ones highlighted or marked as selected).
FIX:
The following 4GL code sample demonstrates how to modify the SCREEN-VALUE as each item is deselected. Run the procedure and select one or more items in the selection-list. Then, each time you press the button, notice that one item is deselected. This procedure removes the first entry each time.
Alternatively, you could remove any item as long as you can use the ENTRY and/or LOOKUP functions to locate it in the SCREEN-VALUE list. The code is:
/* deselect.p */
DEFINE VARIABLE mylist AS CHARACTER NO-UNDO.
DEFINE VARIABLE x AS INTEGER NO-UNDO.
DEFINE VARIABLE select-1 AS CHARACTER NO-UNDO
VIEW-AS SELECTION-LIST MULTIPLE INNER-CHARS 9 INNER-LINES 5
LIST-ITEMS "itemone","itemtwo","itemthree","itemfour","itemfive".
DEFINE BUTTON btn-deselect LABEL "Deselect Item".
DEFINE FRAME theframe select-1 btn-deselect.
ON CHOOSE OF BTN-DESELECT IN FRAME theframe /* Deselect Item */
DO:
ASSIGN mylist = select-1:SCREEN-VALUE.
/* Remove the first item selected from the screen-value list */
ENTRY(1,mylist) = "".
/* Now, modify screen-value to reflect the removal of one selected item */
ASSIGN x = LENGTH(mylist).
IF SUBSTRING(mylist,1,1) = "," THEN
ASSIGN mylist = SUBSTRING(mylist,2,(x - 1)).
/* Before updating, we have to wipe out existing screen-value */
ASSIGN select-1:SCREEN-VALUE = ""
select-1:SCREEN-VALUE = mylist.
END.
ENABLE ALL WITH FRAME theframe.
WAIT-FOR CLOSE OF This-Procedure.
/* end deselect.p */