Search code examples
openedgeprogress-4gl

How to specify a list of items/item pairs for a selection list, containing commas, at design time?


I am creating a selection-list, which needs to contain a list of names of persons. Currently, it looks as follows:

DEFINE VARIABLE sl-competitors AS CHARACTER FORMAT "X(60)":U
 LABEL "Competitors"
 VIEW-AS SELECTION-LIST MULTIPLE SCROLLBAR-VERTICAL
 LIST-ITEM-PAIRS "Alley Anna", "1", "Bower Bob", "2", "Chaplin Charlie", "3", "Drew Derek", "4", "Evon Eve", "5"

This is not what I want: I want the surname and the first name to be separated by a comma. Obviously this means that the delimiter, to be used in the selection-list, should be something else, and I agree with using a pipe character ("|", ASCII code 124).

However, it seems not to be possible to add a DELIMITER attribute at design time:

DEFINE VARIABLE sl-competitors AS CHARACTER FORMAT "X(60)":U
LABEL "Competitors"
DELIMITER "|" or DELIMITER 124 <== this is not accepted.
VIEW-AS SELECTION-LIST MULTIPLE SCROLLBAR-VERTICAL
LIST-ITEM-PAIRS "Alley Anna", "1", "Bower Bob", "2", "Chaplin Charlie", "3", "Drew Derek", "4", "Evon Eve", "5"

Also, adding commas in the names seems to give problems:

DEFINE VARIABLE sl-competitors AS CHARACTER FORMAT "X(60)":U
LABEL "Competitors"
VIEW-AS SELECTION-LIST MULTIPLE SCROLLBAR-VERTICAL
LIST-ITEM-PAIRS "Alley, Anna", "1", "Bower, Bob", "2", "Chaplin, Charlie", "3", "Drew, Derek", "4", "Evon, Eve", "5"

This is most probably caused by the fact that by default a comma is used.

How can I define the delimiter and the list of names, containing commas, at design time?

The usage of tools (appBuilder, PDSOE) is not helpful, as they don't allow to modify the delimiter.


Solution

  • you can do it later in the main-block or anywhere you want

    Define Variable

    DEFINE VARIABLE sl-competitors AS CHARACTER 
     VIEW-AS SELECTION-LIST MULTIPLE SCROLLBAR-VERTICAL
    

    Assign List-Items

    sl-competitors:DELIMITER = "|".
    sl-competitors:LIST-ITEM-PAIRS = "Alley, Anna|1|Bower, Bob|2|Chaplin, Charlie|3|Drew, Derek|4|Evon, Eve|5".