Forum Discussion
Hi shenyusun,
Thanks for the reply. I will try that out.
I would also like to know how i can call the variable which declared inside a function in Unit1 file from a Unit2 file
I think when you declared a variable inside a function, the variable becomes private variable, and it can only be access within the function itself.
- tristaanogre8 years agoEsteemed Contributor
As shenyusun, it's a matter of scope... the variable in the function is scoped to only be accessible within the function.
If you were using JScript or JavaScript you could do something like this:function MyTest(){ this.MyVar = 'testing'; } function test1(){ TestVar = new MyTest(); Log.Message(TestVar.MyVar); }
What this basically does is turn the first function into an object declaration with a property called "MyVar". Again, I don't know Python very well so I don't know if this is possible. But this is how I would do it in a different language.
Related Content
Recent Discussions
- 6 hours agomarkos