Suppose you have a list of phone numbers.
You want to send an sms msg only to numbers that have "55" in it...
How do I branch to an action block for each list element?
for ( number in numberlist ) {
if( contains(number, "55") ) {
// how to branch out to "Send SMS" action?
}
}
Thanks!
Branch to action block for each list element
Moderator: Martin
Re: Branch to action block for each list element
If you use for() loop, you can't. You must use while() or other if() version.
In this case, you don't have to break out the loop to the send SMS. You simply add all number which have "55" to a new list and then loop SMS to all the number.
{sendnum} now contains all the number those have "55".
To loop send SMS to all of this, you can use action Send SMS + condition expression. Add a new line script in previous script
At the action send SMS, use {sendnum[index]} as the number. Then next is expression
false, loop back to Send SMS. This will now tell send SMS to send to the second number (and so on until finish). True, do nothing, essentially stopping the loop/flow.
In this case, you don't have to break out the loop to the send SMS. You simply add all number which have "55" to a new list and then loop SMS to all the number.
Code: Select all
sendnum = newList();
for(number in numberlist)
{
if(contains(number, "55")
addElement(sendnum, number)
}
To loop send SMS to all of this, you can use action Send SMS + condition expression. Add a new line script in previous script
Code: Select all
index = 0;
Code: Select all
index = index + 1;
index > length(sendnum);
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.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Re: Branch to action block for each list element
Thanks. I started down that road, but thought there might be a better way.
Thanks! I appreciate the detailed response.
Thanks! I appreciate the detailed response.