Sorting listbox entries via Array/Json load, doesnt work

Discussion and feedback on Construct 2

Post » Thu Apr 10, 2014 9:45 am

Hi,

I need to add, remove names in list box. The names need to be sorted, no more than 20 names right now. I tried to us Array for sorting and then load the sorted values into the listbox, but it didnt work. Any idea why not?

Here is the essential code:

ButtonAdd onClick & not TextBox is ""

Array Push back TextBox.Text on X axis
Array Sort X axis
List set from JSON string Array.AsJSON



thanks,

Daniel
B
8
S
4
G
1
Posts: 205
Reputation: 1,354

Post » Thu Apr 10, 2014 10:11 am

Hi,

In the meantime I wasn't able to understand why the json based code doesn't work, but was able to solve the sorting the following way:

ButtonAdd onClick & not TextBox is ""

- Array Push back TextBox.Text on X axis
- Array Sort X axis
-- Array For each X element
--- Array Current value =/= 0 List Add Item Array.CurValue

Also in the Array property menu the dimension of the array has to be set to 1 on each dimension: Width=1, Height=1, Depth=1 otherwise this doesnt work.

Note that I had to set the condition Array Current value =/= 0, otherwise an empty line would appear in the listbox. This is because the array is prefilled with a first value of zero, because i had to set Width to 1, for the array to receive add values.

It works, but since i am always interested in learning new techniques, any ideas how to do this better would be much appreciated.
B
8
S
4
G
1
Posts: 205
Reputation: 1,354


Return to Construct 2 General

Who is online

Users browsing this forum: LaDestitute and 25 guests