Automagic script compatibility

Post your questions and help other users.

Moderator: Martin

Post Reply
Friend1
Posts: 52
Joined: 03 May 2017 06:00

Automagic script compatibility

Post by Friend1 » 31 Aug 2018 12:17

Hi Martin,

Automagic script is compatible with any external script? Or it is specific for Automagic? I need detailed script help. Thank you. :|

User avatar
digitalstone
Posts: 342
Joined: 21 Oct 2017 12:36
Location: The Netherlands

Re: Automagic script compatibility

Post by digitalstone » 31 Aug 2018 17:27

Well i'm not Martin, but if you would place an action element anywhere, go inside and tap the questionmark, you'll get an insane amount of help already.
Furthermore, to my own experience at least, the script used inside Automagic is best to be compared with Javascript.
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)

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

Re: Automagic script compatibility

Post by Desmanto » 02 Sep 2018 17:07

You mean to call other script? Only java method are supported. Automagic scripting itself is heavily influenced by java and javascript. We have a massive documentation on every function already, except probably the java method. (which supposed to refer android itself).

You can find all detailed script documentation, pattern character, regex, Control UI and many more at my index - General - Automagic Help and Various Documentation. Those are Automagic built-in documentation, I only link them there for easier access.

If you want more example of usage, you should see the section Scripting.
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.

Friend1
Posts: 52
Joined: 03 May 2017 06:00

Re: Automagic script compatibility

Post by Friend1 » 03 Sep 2018 05:41

Thank you for replies;

For example i need to use CASE statment for multiple conditions. It's possible? I use Automagic premium version 1.35. Please give me a basic example for CASE usage if possible. I look at the script section. But can't find any information except that: viewtopic.php?f=5&t=7255. Thanks for your help.

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

Re: Automagic script compatibility

Post by Desmanto » 03 Sep 2018 17:50

Unfortunately, until now we still can't use CASE yet. It is reserved but not yet implemented. You can use the method in the link, using map object. Or for CASE alternative, it is actually a series of if-else.

Code: Select all

fruit = "apple";
msg = "You have selected ";

if(fruit == "apple")
{
  msg = msg + "red apple";
}
else if(fruit == "banana")
{
  msg = msg + "yellow banana";
}
else if(fruit == "cherry")
{
  msg = msg + "red cherry";
}
else
{
  msg = "You don't select any of the fruit";
}
Yeah, there is no shortcut to do this now. You can remove the else, but that will make each if() not mutually exclusive anymore. Means that several if() can be executed if the condition is true for the case. Using else will make sure only one of the if() get executed, not the other.

I actually have the similar usage case, and I use several if() but not with else. As I have make sure each condition is unique, so I don't put else to protect them. The execution speed is the same.
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