Hi
only a question:
is it possible example
in main program to catch a local variable from a macro like this
flowchart
main...calc....calc2
in main
mainglobal=calc.local + calc2.local
and / or
is it possible in a macro to catch a localvariable from main / macro like
calclocal = main.local + calc2.local
Thank you!
Rudi
Global Variable / Local Variable crossing
-
- Flowcode v5 User
- Posts: 211
- Joined: Tue Feb 19, 2013 9:51 pm
- Has thanked: 72 times
- Been thanked: 177 times
- Contact:
Re: Global Variable / Local Variable crossing
Using global variables would make it very simple. Using local variables is possible, but I don't understand the advantage. Attached is a program using only local variables. I am still learning V6 so maybe an experienced V6 programmer can come up with a better way.
- Attachments
-
- pass a local variable.fcfx
- (4.56 KiB) Downloaded 260 times
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
- Contact:
Re: Global Variable / Local Variable crossing
No, this is not possible. After you leave a macro the local variables are destroyed and the values are lost.Rudi wrote:in main program to catch a local variable from a macro like this
flowchart
main...calc....calc2
in main
mainglobal=calc.local + calc2.local
If you need access to a variable from multiple macros (main and another macro):Rudi wrote:is it possible in a macro to catch a localvariable from main / macro like
calclocal = main.local + calc2.local
1) If you do not need to modify the variable, use it as an argument to the macro call. That way you know it is being used in the macro.
2) If only one variable needs to be modified, return the value from the macro and assign it in the calling macro.
3) If you need to modify multiple variables, use global variables. It is good programming practice to avoid using global variables and assigning them values in macros as much as possible as it is hard to trace where and when global variables are modified.
Examples of the points above:
"glob1" and "glob2" are examples of 1 in the list above. ".loc1" is example of 2.
"glob4" and "glob5" are examples of 3.
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis