Page 1 of 1

Best way to temporarily store results?

Posted: 08 Mar 2013 09:07
by TadW
I am looking for ways to store results for conditionals that can be queried by conditionals later flows.

For example, I have a typical flow that enables and disables airplane mode at certain times. But there situations where I don't want this to happen. For instance, when I am on an airplane...

So, my idea was to add a conditional to the "disable airplane mode"-flow that checks whether the phone is in airplane mode, either because of manual user invention, or because previously the "enable airplane mode"-flow was executed.

If it was due to manual user invention (i.e. me clicking on airplane mode before the plane takes off), then I want a conditional in the "disable airplane mode" to detect this and stop the flow (without disabling airplane mode).

So in practical terms, I would enable a conditional in the "enable airplane mode"-flow to see if the phone is already in airplane mode. If it is not, I would __somewhere__ save a boolean in a variable before continuing the flow. Later then in the "disable airplane mode" I could check if this boolean was set. If it wasn't, the flow would know that the airplane mode was triggered manually and hence it wouldn't continue to disable airplane mode.

So, one way I thought this might be possible is to save the boolean status in an external file through Automagic and then later read that file again. Is that how it works? What would be nicer, and more efficient, but I think doesn't exist right now, would be an option to set and get variables that would then be stored in the local SQL database of Automagic.

Re: Best way to temporarily store results?

Posted: 08 Mar 2013 10:20
by giovag7
Your reasoning is a bit complicated!
I'm not sure if i understood but try this:
First flow: automatic enable/disable airplane mode at certain time.
Second flow: Set a shortcut to manually enable/disable airplane mode and in this flow add an action that enable/disable the first flow

something like this (you have to create the first flow that automatically enable/disable airplane mode)::

http://dl.dropbox.com/u/59740820/export ... 111514.xml

Re: Best way to temporarily store results?

Posted: 08 Mar 2013 13:44
by TadW
Thanks! You're right - your approach is a lot easier and definitely better in this regard.

Generally speaking I think it would still be a nice addition to allow flows to temporarily data as database values.

Re: Best way to temporarily store results?

Posted: 08 Mar 2013 14:21
by Martin
You can also use a global variable in an action Script to store the boolean value:
global_xyz = true;

Global variables are also persisted and available when you restart Automagic or reboot the device.

Re: Best way to temporarily store results?

Posted: 08 Mar 2013 16:25
by TadW
Martin wrote:You can also use a global variable in an action Script to store the boolean value:
global_xyz = true;

Global variables are also persisted and available when you restart Automagic or reboot the device.
Nice! I just discovered global variables reading the help file. Thanks again, it's all that's needed! :P