[Closed] maxmultilistbox selected names problem
hi ,
iam just trying to put a multilist box and storing some names and using selected obj in
some other functions …
but i am not able to retreive the names of selected objects
as in multilistbox there is no property like .selected in other listboxes…
ex.
on multListBox0 selected i do
(
morpharr1=multListBox0 .items— storing initial name here
mor_num1=multListBox0 .selection -- storing selected items in array
--now i wanna the names of selected objects
--like in dropdownlist we are using .selected
)
i need the names as iam wiring the selected objects with a slider…
— one more thing if i had list having names like 1.sphere01,2.sphere02 3.sphere03 4.spher04
if i select first and 3rd i get output from mor_num1=multListBox0 .selection
as #(1,3) i wanna name of 1 and 3
but if i select 1 2 and 4 it comes like (1…2,4)
— and if i wanna use mor_num1.count and select only first object then also it shows count as 4 the total no of objects in the list…
— finally i wanna store the selected objects name as iam using it how can it be possible???
akesh.kulmi
Uhhmmmm, #{} is not the same as #(). The multilistbox is returning a BITARRAY (see Help for details), with a bit set for each entry.
You can convert a bitarray to an array if you want, but you don’t have to. You can use FOR loops to iterate through bitarrays just like with arrays:
theNames = for i in multListBox0.selection collect multListBox0.items[i]
This will collect the selected names from the box into an array and assign to the variable theNames.
Hope this helps.
Here is a full test case:
(
rollout test "Test"
(
multilistbox testbox "Test" items:#("MXS","Test","Name")
on testbox selected i do
(
theNames = for i in testbox.selection collect testbox.items[i]
format "%
" theNames
)
)
createDialog test
)