Arrays to Variables


Donald Walker

Most of the selector controls if not all of them use the array protocal to store the list. I think I need some clarification on how to use these items.

I think I understand how to get the list into the array and also get them out using the GetOptions (I think). But what to do with them at that point?

Can you show some code that would take me from getting my selected item in a dropdown control all the way to where it is stored as a variable that I can use. I may be making a lot more of this than it is but would like to see the right way to do it.

Also the Index, what is that all about and what is correct configuration if it is required.

:-) It is always something hey David?


decsoft

Hello Donald,

Yes; certain controls base their functionallity in Array variables. This is good, because, we can creates Array variables too, and uses all the Arrays related actions for both control's Array variables and our own Array variables.

For example, if we are talking about Select controls, we always can get the currently selected item using a code like this:

The first argument is the Array from we want to get an specific item. In this case such Array is the Select control "Items" Array, but remember we can use this same action with any Array variable.

The second argument is the "index" we want to get from the Array. The Arrays stores the items in a zero based index, so the first item is the "0" (zero), the second item is the "1", and so on. The Select controls offer to us the "ItemIndex" variable, which stores the currently selected item in the control.

The third argument is the result variable, that is, the variable which stores the item we get from the specified Array.

Above we say the Select's "ItemIndex" stores the currently selected item in the control, and, we also can write this variable in order to select an item programatically, just by using the SetVar action:

The above action establish the first item in the Array (zero indexed, remember) as the selected item in the Select control.

As I said above, we can play with all the Arrays related actions, so, for example, we can add a new item at the end of a Select control:

We can add a new item at the start of a Select control:

We can concat a "Select2" control items into a "Select1" control items:

We can remove the last element form of a Select control:

Or remove the first element:

And finally we can continue using the other Array related actions to reverse the items, short them in various ways, search for items, etc., etc. You can start with the NewArray action in the help file and continue scrolling down for other Arrays related actions.

If you have any further question just post it Donald. :)



Donald Walker

Excellent David. That is very useful info. Thanks


decsoft

You're welcome sir! :)


Todo el mundo puede leer el foro de soporte de DecSoft para aprender del mismo, sin embargo, sólo los clientes de DecSoft pueden abrir nuevos hilos. Compre una o más licencias de productos de DecSoft y obtendrá este y otros beneficios.

Este sitio utiliza "cookies" útiles para almacenar sus preferencias.

Bien. Ocultar esta nota. Obtener más información.