Subroutine call to another flow.

Post your questions and help other users.

Moderator: Martin

User avatar
husky
Posts: 132
Joined: 29 Oct 2016 13:41
Location: Omaha, Nebraska, USA
Contact:

Subroutine call to another flow.

Post by husky » 29 Nov 2016 17:35

Hello,

Making it simple:
Flow1 and flow2 and flow3,.... flown (n-th flow)

Their functions is life are different but they all share a common script, say date and time.
As far as I understand, all n flows will carry the same code to generate the date and time.
(date=getDate.../ time=getDate...).

Question:
Is there a way to code the date/time script only once and have it called by all n flows withot having to write (or copy) the script in each flow.
I think something like : (not sure the example is the best way but should give some idea)

Function TimeDate(){
date=GetDate.......;
time=getDate......;
)

and in the flows have a script as TimeDate()

Thank You

Husky
"Basic research is what I'm doing when I don't know what I'm doing"

User avatar
MURTUMA
Posts: 697
Joined: 05 Mar 2013 22:43

Re: Subroutine call to another flow.

Post by MURTUMA » 29 Nov 2016 21:08

You can save data in global_variables. Global vars can be accessed by any flow at any time.

global_date = getDate();

User avatar
husky
Posts: 132
Joined: 29 Oct 2016 13:41
Location: Omaha, Nebraska, USA
Contact:

Re: Subroutine call to another flow.

Post by husky » 29 Nov 2016 21:42

Murtuma,

Thank you for the reply.

I need a bit more to understand the reply.

Please advice in the case my interpretation is way off.

I would have to define the date/time script in only one of the n flows.

if so, then all (n-1) won't have to have the full script already defined. Just get the global's content and go from there.

If this interpretation is correct, then the one with the Date/time script willl have to be active at all times.
I coded a flow that every 7:00 am launches all the flows .
In this case the best way would be code the "global" script in this "starter flow".

Is this a correct interpretation/approach?

Sorry if I sound too dumb, but after 30 years as IBM systems programmer, my logic is always taking me towards the IBM assembler and then the front crash with new (for me) technologies.

Regards

Husky
"Basic research is what I'm doing when I don't know what I'm doing"

P-chu
Posts: 32
Joined: 05 Nov 2016 19:12

Re: Subroutine call to another flow.

Post by P-chu » 01 Dec 2016 00:25

Hi Husky,

I think (at least how I would approach it) the idea is to put your Date & Time script in its own flow that would store the values in a global variable that your other flows can reference. Then as you have mentioned, the Date & Time flow would be always active if it is triggered each time the date/time changes (¿trigger "Time Adjusted?). On the other hand, you could instead have your other flows call the Date & Time flow with an action "Execute Flows", and then get the values from the global variables.

Hope that helps. (Must have been nice working for IBM.)
P-chu

User avatar
MURTUMA
Posts: 697
Joined: 05 Mar 2013 22:43

Re: Subroutine call to another flow.

Post by MURTUMA » 01 Dec 2016 19:24

I was going to suggest something similar as P-chu. However, there are multiple ways to approach this problem. What is the best depends entirely on the use case. Please, explain in more detail how the set of flows work, mainly how they are(should be) triggered?

User avatar
husky
Posts: 132
Joined: 29 Oct 2016 13:41
Location: Omaha, Nebraska, USA
Contact:

Re: Subroutine call to another flow.

Post by husky » 02 Dec 2016 16:12

P-Chu,MURTUMA

So far I created 5 monsters.

They work fine with the Date/Time being fetched in the body of each different functional flow, i e, each flow has its own Date/Time Script. (I personally hate redundancy)

Give me some time to create a test flow with your suggestion and see what happens. Be back to you as soon as I have your idea implemented an running. At this point I do not want to touch my monsters. Don't want to break what is is not needed to be brooken.

Yes working with mainframes since 1977. Best year years of my life. Retired now.

Regards

Husky

SInce I do not know if I can post a second reply just for Murtuma after replyin to P-Chu, so below is the reply to MURTUMA.

1. Very kindergarted flows.
2. Start of times: at 7:00 am I kick off a Starter Flow that loads and executes all the flows till 10:00 pm.
3. All flows write data to a txt file so I can start seeing some patterns and adjust timings and go into some statistcal B.S.
4. FLOWS:
Battery Level flow, check battery percentage every 10 minutes(this timing might not be good, but works for now. I cannot say how much CPU and resources are used by each flow ).
Battery Temperature, same concept as above, but checks temperature every 5 minutes.
Location based Wi-Fi, check every 30 minutes if I'm at home or away. Running this just as a test now. Later this flow wll be manually started.
WiFi Check, every 30 minutes check if my provider let me down. No wifi connection warning.

As you see all flows run the same Date/Time script imbedded in each flow.
So here's where I need to know how to code one version in a separate flow and call it for all other existing and future floes.

All flows are triggered by Period Timer At this point I wonder if the starter flow is needed, since all flows start at different times( and finish at the same time (10:00pm).

After all this messy explanation I hope some usefull info was worth your time. Also will be way more succinct in all my replys.

Regards

Husky
"Basic research is what I'm doing when I don't know what I'm doing"

User avatar
husky
Posts: 132
Joined: 29 Oct 2016 13:41
Location: Omaha, Nebraska, USA
Contact:

Re: Subroutine call to another flow.

Post by husky » 02 Dec 2016 19:21

Well guys,

The solution for the redundancy was screamming at me and I couldn't hear it.

Created a SCRIPT flow with all the common global variables to all flows. After that, I removed the corresponding individual scripts and no redundancy anymore.

Pretty nice solution right in front of my nose.

Thanks for all the help and advices. You are an excellent team.

Regards


Husky
"Basic research is what I'm doing when I don't know what I'm doing"

User avatar
MURTUMA
Posts: 697
Joined: 05 Mar 2013 22:43

Re: Subroutine call to another flow.

Post by MURTUMA » 02 Dec 2016 23:26

husky wrote:Created a SCRIPT flow with all the common global variables to all flows. After that, I removed the corresponding individual scripts and no redundancy anymore.
This would have been my next suggestion but fortunately you figured it on your own. Good thing you're starting to learn!

P-chu
Posts: 32
Joined: 05 Nov 2016 19:12

Re: Subroutine call to another flow.

Post by P-chu » 03 Dec 2016 18:33

MURTUMA wrote:This would have been my next suggestion but...
i'm curious what would have been your first suggestion, Murtuma? Always nice to learn something new. :)
P-chu

User avatar
MURTUMA
Posts: 697
Joined: 05 Mar 2013 22:43

Re: Subroutine call to another flow.

Post by MURTUMA » 04 Dec 2016 14:03

@P-chu: When using a set of multiple flows which interacts and/or affects eachothers via global vars, it might come handy to have one flow to centrally store, keep tabs and update those global vars. In some cases this is unnecessary but in others it could make managing the actual working flow easier and more convenient.

One case where it could prove handy is, if you're using many flows with location condition. Having only one flow to keep tabs on current location or storing multiple locations could ease the workload of other flows.

Post Reply