SELECTION-LIST SET AS LIST-ITEM-PAIRS

Posted by Ab Himmit on 25-Jul-2016 10:23

What is the program syntax for selecting the entries of a selection-list set as a list-item-pairs before the screen is displayed?

Thanks for your help,

All Replies

Posted by Brian K. Maher on 25-Jul-2016 10:28

set the widgets screen-value attribute.
 

Posted by Ab Himmit on 25-Jul-2016 10:31

I know that I have to set the screen-value of the widget. But how do I do that for a selection-list as a list-item-pairs?

Thanks,

Posted by Brian K. Maher on 25-Jul-2016 10:44

Given a selection list named select-1 with a list-item-pairs value of “AAA,1,BBB,2,CCC,3,DDD,4,EEE,5” the code to select “BBB” and “EEE” would be
 
select-1:screen-value in frame {&frame-name} = "2,5".
 
is that clear enough?

Posted by Ab Himmit on 25-Jul-2016 10:57

Instead of numeric values, I have characters values.

My list is build as "Agent,AGE,Customer,CUS,Vendor,VEN,....)

I have already tried this;  ASSIGN lst_Addrtype:SCREEN-VALUE IN FRAME {&FRAME-NAME} = "AGE,CUS,VEN".

But this statement does not work.

Posted by Brian K. Maher on 25-Jul-2016 11:08

Ab,
 
Then post your code so we can actually help you.  A cycle of “ask question, get answer, reply that answer didnt work” without providing all of the info that we all need to give a completely accurate answer is, to be honest, a tad annoying.  When we are provided with very limited information we gave a basic answer which, generally, is correct.  If it doesn’t work then there is something non-general about how your code is written.
 
TL;DR version -> help us to help you
 
:-)
 

Posted by Darrick Bush on 25-Jul-2016 11:23

You don't use screen-value....Here is some sample code

def var mylist as character view-as selection-list INNER-CHARS 15 INNER-LINES

10 SORT.

def var mylist2 as character.

define frame frmA

   mylist

   with side-labels overlay.

assign mylist2 = "Dolphins,D,Elephants,E,Cougars,C".

assign mylist:LIST-ITEM-PAIRS = mylist2.

enable mylist with frame frmA.

Wait-for window-close of current-window.

Posted by Brian K. Maher on 25-Jul-2016 11:25

&Scoped-define WINDOW-NAME C-Win
/*------------------------------------------------------------------------

  File: 

  Description: 

  Input Parameters:
      <none>

  Output Parameters:
      <none>

  Author: 

  Created: 

------------------------------------------------------------------------*/
/*          This .W file was created with the Progress AppBuilder.      */
/*----------------------------------------------------------------------*/

/* Create an unnamed pool to store all the widgets created 
     by this procedure. This is a good default which assures
     that this procedure's triggers and internal procedures 
     will execute in this procedure's storage, and that proper
     cleanup will occur on deletion of the procedure. */

CREATE WIDGET-POOL.

/* ***************************  Definitions  ************************** */

/* Parameters Definitions ---                                           */

/* Local Variable Definitions ---                                       */



/* ********************  Preprocessor Definitions  ******************** */

&Scoped-define PROCEDURE-TYPE Window
&Scoped-define DB-AWARE no

/* Name of designated FRAME-NAME and/or first browse and/or first query */
&Scoped-define FRAME-NAME DEFAULT-FRAME

/* Standard List Definitions                                            */
&Scoped-Define ENABLED-OBJECTS SELECT-1 BUTTON-1 
&Scoped-Define DISPLAYED-OBJECTS SELECT-1 

/* Custom List Definitions                                              */
/* List-1,List-2,List-3,List-4,List-5,List-6                            */

/* ***********************  Control Definitions  ********************** */

/* Define the widget handle for the window                              */
DEFINE VAR C-Win AS WIDGET-HANDLE NO-UNDO.

/* Definitions of the field level widgets                               */
DEFINE BUTTON BUTTON-1 
     LABEL "Button 1" 
     SIZE 15 BY 1.14.

DEFINE VARIABLE SELECT-1 AS CHARACTER 
     VIEW-AS SELECTION-LIST MULTIPLE SCROLLBAR-VERTICAL 
     LIST-ITEM-PAIRS "Agent","AGE",
                     "Customer","CUS",
                     "Vendor","VEN" 
     SIZE 40 BY 5.24 NO-UNDO.


/* ************************  Frame Definitions  *********************** */

DEFINE FRAME DEFAULT-FRAME
     SELECT-1 AT ROW 2.43 COL 10 NO-LABEL WIDGET-ID 2
     BUTTON-1 AT ROW 10.29 COL 29 WIDGET-ID 4
    WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY 
         SIDE-LABELS NO-UNDERLINE THREE-D 
         AT COL 1 ROW 1
         SIZE 80 BY 16 WIDGET-ID 100.


/* *********************** Procedure Settings ************************ */

/* Settings for THIS-PROCEDURE
   Type: Window
   Allow: Basic,Browse,DB-Fields,Window,Query
   Other Settings: COMPILE
 */

/* *************************  Create Window  ************************** */

IF SESSION:DISPLAY-TYPE = "GUI":U THEN
  CREATE WINDOW C-Win ASSIGN
         HIDDEN             = YES
         TITLE              = "<insert window title>"
         HEIGHT             = 16
         WIDTH              = 80
         MAX-HEIGHT         = 16
         MAX-WIDTH          = 80
         VIRTUAL-HEIGHT     = 16
         VIRTUAL-WIDTH      = 80
         RESIZE             = yes
         SCROLL-BARS        = no
         STATUS-AREA        = no
         BGCOLOR            = ?
         FGCOLOR            = ?
         KEEP-FRAME-Z-ORDER = yes
         THREE-D            = yes
         MESSAGE-AREA       = no
         SENSITIVE          = yes.
ELSE {&WINDOW-NAME} = CURRENT-WINDOW.
/* END WINDOW DEFINITION                                                */



/* ***********  Runtime Attributes and AppBuilder Settings  *********** */

/* SETTINGS FOR WINDOW C-Win
  VISIBLE,,RUN-PERSISTENT                                               */
/* SETTINGS FOR FRAME DEFAULT-FRAME
   FRAME-NAME                                                           */
IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(C-Win)
THEN C-Win:HIDDEN = no.


 



/* ************************  Control Triggers  ************************ */

&Scoped-define SELF-NAME C-Win
ON END-ERROR OF C-Win /* <insert window title> */
OR ENDKEY OF {&WINDOW-NAME} ANYWHERE DO:
  /* This case occurs when the user presses the "Esc" key.
     In a persistently run window, just ignore this.  If we did not, the
     application would exit. */
  IF THIS-PROCEDURE:PERSISTENT THEN RETURN NO-APPLY.
END.


ON WINDOW-CLOSE OF C-Win /* <insert window title> */
DO:
  /* This event will close the window and terminate the procedure.  */
  APPLY "CLOSE":U TO THIS-PROCEDURE.
  RETURN NO-APPLY.
END.


&Scoped-define SELF-NAME BUTTON-1
ON CHOOSE OF BUTTON-1 IN FRAME DEFAULT-FRAME /* Button 1 */
DO:
  select-1:screen-value in frame {&frame-name} = "AGE,CUS,VEN".
END.


&UNDEFINE SELF-NAME



/* ***************************  Main Block  *************************** */

/* Set CURRENT-WINDOW: this will parent dialog-boxes and frames.        */
ASSIGN CURRENT-WINDOW                = {&WINDOW-NAME} 
       THIS-PROCEDURE:CURRENT-WINDOW = {&WINDOW-NAME}.

/* The CLOSE event can be used from inside or outside the procedure to  */
/* terminate it.                                                        */
ON CLOSE OF THIS-PROCEDURE 
   RUN disable_UI.

/* Best default for GUI applications is...                              */
PAUSE 0 BEFORE-HIDE.

/* Now enable the interface and wait for the exit condition.            */
/* (NOTE: handle ERROR and END-KEY so cleanup code will always fire.    */
MAIN-BLOCK:
DO ON ERROR   UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK
   ON END-KEY UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK:
  RUN enable_UI.
  IF NOT THIS-PROCEDURE:PERSISTENT THEN
    WAIT-FOR CLOSE OF THIS-PROCEDURE.
END.


/* **********************  Internal Procedures  *********************** */

PROCEDURE disable_UI :
/*------------------------------------------------------------------------------
  Purpose:     DISABLE the User Interface
  Parameters:  <none>
  Notes:       Here we clean-up the user-interface by deleting
               dynamic widgets we have created and/or hide 
               frames.  This procedure is usually called when
               we are ready to "clean-up" after running.
------------------------------------------------------------------------------*/
  /* Delete the WINDOW we created */
  IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(C-Win)
  THEN DELETE WIDGET C-Win.
  IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
END PROCEDURE.

PROCEDURE enable_UI :
/*------------------------------------------------------------------------------
  Purpose:     ENABLE the User Interface
  Parameters:  <none>
  Notes:       Here we display/view/enable the widgets in the
               user-interface.  In addition, OPEN all queries
               associated with each FRAME and BROWSE.
               These statements here are based on the "Other 
               Settings" section of the widget Property Sheets.
------------------------------------------------------------------------------*/
  DISPLAY SELECT-1 
      WITH FRAME DEFAULT-FRAME IN WINDOW C-Win.
  ENABLE SELECT-1 BUTTON-1 
      WITH FRAME DEFAULT-FRAME IN WINDOW C-Win.
  {&OPEN-BROWSERS-IN-QUERY-DEFAULT-FRAME}
  VIEW C-Win.
END PROCEDURE.

Posted by Brian K. Maher on 25-Jul-2016 11:28

Darrick,
 
That is correct for assigning the values of list-item-pairs but Ab wants to define which ones get visually selected within the selection list.
 
Ab .. I have sent a complete program from the AppBuilder which works.
 
Brian

Posted by Ab Himmit on 25-Jul-2016 11:35

Thanks you All,

I appreciate all the help.

I think the difference between your example and myn is;

-You are selecting the items using a button; This means the screen is already visible.

-I'm selecting the items before the screen is displayed. So the assign seems to be working, but the widget is not displayed with selected items when it is shown.

Regards,

Ab

Posted by Brian K. Maher on 25-Jul-2016 11:40

If the selection list is not realized (our term) then you are correct.
 
 

Posted by Ab Himmit on 25-Jul-2016 12:19

Any idea how to overcome this?

I'm setting a toggle-box to checked at the same position, that works well. But the selection list doesn't seem to work, the items are not displayed as selected.

Thanks,

Posted by Ab Himmit on 25-Jul-2016 12:33

Thanks All for your help.

I seems to have solved the issue. I have added a procedure (init_Record) to the main-block where I set the list items to selected. See the snippet below;

MAIN-BLOCK:

DO ON ERROR   UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK

  ON END-KEY UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK:

 RUN enable_UI.

 RUN init_Record.

 IF NOT THIS-PROCEDURE:PERSISTENT THEN

   WAIT-FOR CLOSE OF THIS-PROCEDURE.

END.

Now the the list are displayed selected when the screen is shown.

Posted by Brian K. Maher on 25-Jul-2016 12:34

Ab,
 
You will either need to provide full code that we can run or, even better, open an official support request with tech support (which is my department here at PSC).
 
Brian

Posted by Brian K. Maher on 25-Jul-2016 12:38

That would do it, mainly because the RUN of enable_UI would have realized the UI widgets.

This thread is closed