Arrays with Action Blocks: weird bug?

Andydroid

Member
Unless my understanding of arrays is wrong (it could well be), this is a weird bug (v5.30.7 Pro).

In a macro, I have an array of decimals with seven entries. If I set up a loop to set each entry to a fixed value eg 1.0, it works fine:
Screenshot_1.jpg

However, if I try to do this via an Action Block, the last six of the seven array entries get deleted!
Screenshot_2.jpg

This is the Action Block:
Screenshot_3.jpg

The weird part is that if I don't set the array entries to a fixed value, and instead set them to differing values via an expression, eg {lv=i}, then it works fine with an Action Block!

Am I doing something wrong or is it a bug?...
 

Dimlos

Well-known member
If it were like this, it would work, but it may not be what you want to do.
 

Attachments

  • Set_Variable_Array.macro
    11.8 KB · Views: 3

Dimlos

Well-known member
From what I have tested, repeating Add Array Index does not increase the Index.
I was able to create as many Array Indexes as I needed first and then change the values.
If I create 7 Indexes in the output variable of the action block, it works fine.

Is it a bug that Indexes are not created after repeating Add Array Index?
 

Andydroid

Member
@Dimlos, thanks for looking at this. What I'm actually trying to do is have an Action Block that simply gets a user string of N space separated values and returns an array with N elements containing the values.

Eg if the user input is 11 22 33 44 55 66 77, the Action Block should return the array containing:
a[1] = 11
a[2] = 22
a[3] = 33
a[4] = 44
a[5] = 55
a[6] = 66
a[7] = 77

When the values are different as above, it works fine.

However, if the *initial* values are the same, Macrodroid deletes elements from the array:
eg 11 11 33 44 55 66 77 will delete a[2] from the array, but a[1], a[3], a[4], a[5], a[6], a[7] are correct
eg 11 11 11 44 55 66 77 will delete a[2] and a[3] from the array, but a[1], a[4], a[5], a[6], a[7] are correct
eg 11 11 11 11 55 66 77 will delete a[2], a[3] and a[4] from the array, but a[1], a[5], a[6], a[7] are correct
etc

This is the actual Action Block:
abGetUserInputValues--_2 (2).png
 

Dm114

Well-known member
@Dimlos, thanks for looking at this. What I'm actually trying to do is have an Action Block that simply gets a user string of N space separated values and returns an array with N elements containing the values.

Eg if the user input is 11 22 33 44 55 66 77, the Action Block should return the array containing:
a[1] = 11
a[2] = 22
a[3] = 33
a[4] = 44
a[5] = 55
a[6] = 66
a[7] = 77

When the values are different as above, it works fine.

However, if the *initial* values are the same, Macrodroid deletes elements from the array:
eg 11 11 33 44 55 66 77 will delete a[2] from the array, but a[1], a[3], a[4], a[5], a[6], a[7] are correct
eg 11 11 11 44 55 66 77 will delete a[2] and a[3] from the array, but a[1], a[4], a[5], a[6], a[7] are correct
eg 11 11 11 11 55 66 77 will delete a[2], a[3] and a[4] from the array, but a[1], a[5], a[6], a[7] are correct
etc

This is the actual Action Block:
View attachment 4702
Why don't you use the Text manipulation > Split to array action?

If you don't want to overwrite previous items you could Split to a work array and, then, compare and update final items with work items.
 

Dimlos

Well-known member
I have tested this based on @Dm114 advice, and in this case there seems to be no problem with assignments in the action block.
v5.30.7 Pro is relatively new, but there are newer beta versions out there, and the action block behavior may have changed in those.
If the behavior that you suspect is a bug is not resolved in the latest version, we recommend that you file a bug report in the Troubleshooting section.
 

Attachments

  • Text_to_Array.macro
    3.4 KB · Views: 2

Andydroid

Member
Why don't you use the Text manipulation > Split to array action?

If you don't want to overwrite previous items you could Split to a work array and, then, compare and update final items with work items.
Oh wow, I never noticed that function before, and it works a treat, and so much simpler too- many thanks!

I still believe there's a bug in Action Blocks when doing it my original way though- I'll report it through the app.

Thanks guys!...
 
Top