Hi guys I need your help please.
my script:
smartStates = newList("Smart Rotate","Smart Timeout","Smart Notification");
for (smartState in smartStates)
{
if( contains(smartState,'Rotate' )==true )
{
detail = "on"
}
if( contains(smartState,'Timeout' )==true )
{
detail = "1 minute"
}
if( contains(smartState,'Notification' )==true )
{
detail = "active"
}
smartDetails = concat(smartState, ' (', detail, ')');
}
// string result be in this kind of format
Smart Rotate (on)
Smart Timeout (1minute)
Smart Notification (active)
Thanks....
need help regarding concat function
Moderator: Martin
Re: need help regarding concat function
I am confused what you want to do. If "Smart Rotate" always have the value (on), then why don't just put the value "Smart Rotate (on)" directly? Same for other value.
You can combine them later, using join() and newline
text = join(smartStates, "\n")
Then display it (such as in notification on screen) as {text}
When using loop, it is better to use new variable which is completely different to avoid confusion. I am confused until I realize there is no 's' in the for. Better use
for ( i in smarStates)
Then use i in the loop, save your code, save your typing and avoid confusion.
contains() will always result in true or false, so no need additional "== true" in if()
Since the value comes in pair, maybe you should use map() instead. There is action map values you can use, or map function as well.
You can combine them later, using join() and newline
text = join(smartStates, "\n")
Then display it (such as in notification on screen) as {text}
When using loop, it is better to use new variable which is completely different to avoid confusion. I am confused until I realize there is no 's' in the for. Better use
for ( i in smarStates)
Then use i in the loop, save your code, save your typing and avoid confusion.
contains() will always result in true or false, so no need additional "== true" in if()
Since the value comes in pair, maybe you should use map() instead. There is action map values you can use, or map function as well.
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.
-
- Posts: 33
- Joined: 08 Mar 2013 12:45
Re: need help regarding concat function
Thanks Desmanto for your help and tips in creating scripts. Your idea perfectly work on my flow. Thanks again