LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabPython Global Variables

I reproduce your example. True, for the little I played, it seems that any variable declared global in the main is not visible by PythonGetVariables and PythonGetData. It looks to me as the opposite problem of this thread, by which you had to declare globals all variables to be inherited inside functions, both in the caller and in the called. This hints at a problem of visibility, but does not mean that python has no notion of your global variables.

Would it be an acceptable workaround to use auxiliary variables just for labpython visibility? E.g.

 

global myGlobalVariable

myGlobalVariable=myInputVariable

def foo():
  global myGlobalVariable
  myGlobalVariable += 1

foo()

myOutputVariable=myGlobalVariable

 

Message 11 of 12
(534 Views)

I did actually try this, and it does work - assigning another variable to the global variable value. This would still require me to rewrite the modules I am using. I fear I will have to use command line VI to run my python scripts (which only captures standard output) from labview, which is a shame because labpython has a lot of good things going for it. I've even considered writing my own python-labview extension, I'll have to look into the details of the script node.

 

Thanks for all your help, Enrico.

0 Kudos
Message 12 of 12
(526 Views)