Bug With Arrays since update

BuddyHoli

Member
If you have an array and customized indexes, for example:

Index 30 value 30 minutes
Index 60 value 60 minutes
Index 120 value 120 minutes

And you set these values as choices in a dialog selection box and safe index in an integer var, the saved index is not 30, 60 or 120 but 0, 1 or 2

This worked seamless before the last update.

Buddy
 
  • Like
Reactions: RSF

Dm114

Well-known member
If you have an array and customized indexes, for example:

Index 30 value 30 minutes
Index 60 value 60 minutes
Index 120 value 120 minutes

And you set these values as choices in a dialog selection box and safe index in an integer var, the saved index is not 30, 60 or 120 but 0, 1 or 2

This worked seamless before the last update.

Buddy
The index which is referred to in Selection Dialog is the order the items are displayed (beginning from 0). So it's nearly compulsory to use the same numbering rules with array indexes...

Otherwise use a Dictionary instead of an Array.
 

BuddyHoli

Member
Just wrong. There is the possibility to customize the index number. So, when I save this number in an integer, I expect that my index set is saved to the var.
This worked excellent before the update.

I know that array are indexed from 0 to X. But when 0 to 8 are empty, the index for value of the ninth index would return 0 in this case and this is programmatically completely wrong
 

Dm114

Well-known member
Just wrong. There is the possibility to customize the index number. So, when I save this number in an integer, I expect that my index set is saved to the var.
This worked excellent before the update.

I know that array are indexed from 0 to X. But when 0 to 8 are empty, the index for value of the ninth index would return 0 in this case and this is programmatically completely wrong
I think you misunderstood the way array indexes work. Programmatically you can set any number to an index. Indexes must not be in sequence and they are always retrieved in ascending order. So it's not forbidden to have wholes between index numbers but it can be a bit tricky (even dangerous) in some cases. Having wholes is even not very logical according to arrays.

It's the reason why, if you have keys (indexes) not consecutive, you'd better use dictionary instead. Items will also be retrieved in key ascending order, whenever keys are of string or numeric form.

According to the value of the index returned by Selection Dialog, as I told you previously, it has nothing to deal with the index of an array (if any) but with the rank of the line pressed by the user (1st line=0).

If your array indexes are not consecutive, the index value returned by the Selection Dialog is useless (in this case only)...
 

MacroDroidDev

Administrator
Staff member
If you have an array and customized indexes, for example:

Index 30 value 30 minutes
Index 60 value 60 minutes
Index 120 value 120 minutes

And you set these values as choices in a dialog selection box and safe index in an integer var, the saved index is not 30, 60 or 120 but 0, 1 or 2

This worked seamless before the last update.

Buddy

I am checking on this and will correct in the next update if I can find the problem.
 
Top