Loop differences

Post your questions and help other users.

Moderator: Martin

Post Reply
Nemisorg
Posts: 6
Joined: 24 Nov 2017 09:17

Loop differences

Post by Nemisorg » 27 Nov 2017 15:58

Wat is The difference between loop over list and loop over list (condensed)

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Loop differences

Post by Desmanto » 27 Nov 2017 16:34

Basically the condensed version is as its name, more compact, smaller, more efficient.
But the code is much harder to read (more advanced), since it packs all the script into the condition expression.

Either one will work, but condensed version will less likely to hit Emergency stop, since there are only 2 elements in the loop; while the other has 4 elements.
Condensed version can run for 30 loops before hitting default Emergency stop; while other only for 15 loops.

Use the one you are comfortable with. if you have get used to the script block; you can use the condensed version.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Nemisorg
Posts: 6
Joined: 24 Nov 2017 09:17

Re: Loop differences

Post by Nemisorg » 27 Nov 2017 17:49

Thanks for your fast reply! But when I want to use the loop it ask me for a variable. Why I have to select a variable?

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Loop differences

Post by Desmanto » 27 Nov 2017 18:01

Of course, since the template loop over a list. You must select variable which is a list type. Example

Code: Select all

listvar = newList("a", "b", "c");
If you use listvar as the list, it will show you toast message : a, b, then c.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Post Reply