Conditional branching

Post your questions and help other users.

Moderator: Martin

Post Reply
6j71ma
Posts: 3
Joined: 20 Oct 2018 22:00

Conditional branching

Post by 6j71ma » 21 Oct 2018 10:08

Hi all, new to automatic (AM), I come from macrodroid (MD).
AM is much more reliable than MD, so I'm considering moving to AM.
But I need to get used to AM programming and there are still so many doubts!
The 1st one is conditional branching. Back in MD I could use WHILE REPEAT and IF THEN ELSE conditions, and these don't seem to be there in AM (to be fair, I discovered AM yesterday).
Here is an example : trigger is incoming call, and I want to toggle on and off the flashlight while the phone is ringing. I can choose every action, but how do i set a loop to toggle the flashlight until I answer the phone?
Besides that there are other problems, but one at the time! And congrats to AM developers, it's a great utility.

6j71ma
Posts: 3
Joined: 20 Oct 2018 22:00

Re: Conditional branching

Post by 6j71ma » 21 Oct 2018 10:09

Just to clarify : I want to toggle the torch on and off every 500 Ms, while the phone is ringing only.

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Conditional branching

Post by Martin » 21 Oct 2018 11:00

Hi,

You can add branches to a flow by adding a condition to a flow and then connect the true/false-branches to different actions. You can find an example here: Flow list, open the Menu: Catalog->Location Based WiFi On/Off.
You can also build loops by using a condition. Check out example Countdown from the catalog.

Regards,
Martin

User avatar
Rafi4
Posts: 281
Joined: 01 Dec 2017 05:23

Re: Conditional branching

Post by Rafi4 » 21 Oct 2018 11:03

Hi
Simply download all flows in forum. Study them. You can easily learn more quickly.this is the flow which is required to you. Any doubts?
Post.
Attachments
flash light when ringing.xml
(3.45 KiB) Downloaded 700 times
No.1 Automation app in play store Automagic Premium
Samsung Galaxy j2 non rooted.
Android 5.1.1

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

Re: Conditional branching

Post by Desmanto » 21 Oct 2018 18:17

Welcome on board. You can loop the element by dragging back the element back to its previous one. In this case you want to loop the flash light on - sleep - flash light off - sleep >> loopback to flashlight on. But you want to check in middle, whether the phone is still ringing. So add condition Call State : Ringing.

There is similar concept here : viewtopic.php?f=5&t=7573&p=22143&hilit= ... ent#p22143
Except, replace the speech output with the flash light on/off loop (4 elements)
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.

6j71ma
Posts: 3
Joined: 20 Oct 2018 22:00

Re: Conditional branching

Post by 6j71ma » 21 Oct 2018 22:35

I'm confused and amazed at the same time.
Thanks for your help!
Sure I will try most of the flows, I need to learn Automagic idiosyncrasies

Post Reply