Selection-List: Getting multiple values

Kladkul

Member
I'm working with a selection-list and I'm allowing users to select multiple values in the list. How do I get all of the selected values into a variable?

I can see there is an IS-SELECTED() method but I can't seem to get it to work. Does anyone know how to get this working correctly?
 

Kladkul

Member
Just got a lightbulb:

Code:
    ASSIGN v-list = sel-list:PRIVATE-DATA. 
    DO v-cnt = 1 TO NUM-ENTRIES(v-list):
        v-selected = sel-list:IS-SELECTED(v-cnt). 
        IF v-selected THEN DO: 
            IF v-hosts = "" THEN 
                ASSIGN v-hosts = ENTRY(v-cnt,sel-host:PRIVATE-DATA).
            ELSE 
                ASSIGN v-hosts = v-hosts + "," + ENTRY(v-cnt,sel-host:PRIVATE-DATA).
        END.
    END.

Looks like this will do what I need.
 

lord_icon

Member
Greetings,
I am confused though as long as you have worked it out that`s all that matters.
The syntax you supplied seemed only to use the private-data attribute - this is not seen on the interface.
???
 

Kladkul

Member
Well, I needed the private-data of the items that the user selects. The same would've worked if I used the LIST-ITEMS attribute instead of PRIVATE-DATA.
 

lord_icon

Member
The PRIVATE-DATA attribute, can be anything - it is not used
You can even set set the sttribute to pants if you wanted.
objectName:pRIVATE-DATA = "pants.
The user does not need to know this value.
 

Kladkul

Member
It seems like you aren't understanding the question, either way it doesn't matter. The code does what I need it to
 

Cringer

ProgressTalk.com Moderator
Staff member
The way I understand it, the OP has sent the private data elsewhere, and just wants to enquire on the private data of the entries selected by the user. Makes sense to me. :)
 

Cringer

ProgressTalk.com Moderator
Staff member
Just got a lightbulb:

Code:
    ASSIGN v-list = sel-list:PRIVATE-DATA. 
    DO v-cnt = 1 TO NUM-ENTRIES(v-list):
        v-selected = sel-list:IS-SELECTED(v-cnt). 
        IF v-selected THEN DO: 
            IF v-hosts = "" THEN 
                ASSIGN v-hosts = ENTRY(v-cnt,sel-host:PRIVATE-DATA).
            ELSE 
                ASSIGN v-hosts = v-hosts + "," + ENTRY(v-cnt,sel-host:PRIVATE-DATA).
        END.
    END.
Looks like this will do what I need.

Just a little tip I've found (hope I'm not teaching you to suck eggs), but to get a comma delimited list, the following code is much simpler to read IMO :) It removes the need for the check for a blank v-hosts.

Code:
ASSIGN v-hosts = v-hosts + MIN(v-hosts,",") + ENTRY(v-cnt,sel-host:PRIVATE-DATA).
 
Top