04-11-2014 09:58 AM
Hi,
I have Main_wkGlobal.vi and kGlobal.vi. How can I open the kGlobal when I start the Main_wkGlobal instead of manually open and run kGlobal ?
Thanks,
KN
04-11-2014 10:42 AM
Well fisrt off kGlobal.vi can't run. It is a global variable there is no code to run
Your code has some problems and should be re-thought out. Use an event structure to respond to user inputs. This way you won't burn up the entire CPU re-calculating the same result as often as possible. Seriously, you only need to calculate and update the display when A, B or the operation changes.
What you have is a first-class case of localitis and global abuse. Not to mention that you forgot the programmer's mantra "Code it once!"
A quick revision uses no locals, no globals and no greedy loops
and attached back saved to 8.6 per vi properties
04-11-2014 12:36 PM
Hi Jeff,
Thank you very much for your quick reply. I am learning how to use global, and this is just simple code for learning.This example: I have to open Main_wkGlobal.vi and open kGlobal.vi, then changing the option on the kGlobal.vi the result will calculated on Main_wkGlobal.vi. My question is how to open the kGlobal.vi when I start the Main_wkGlobal.vi ? That mean when I start Main_wkGlobal.vi the kGloble.vi will pop up.
Again thank you very much for your help.
KN
04-11-2014 01:14 PM - edited 04-11-2014 01:18 PM
Well if you MUST, (And I discourage you from abusing a global like that its not what they are designed for)
The FP.Open method works well on Globals Set "Activate="TRUE" to put key focus on the global (even in 8.6 I had to double check that the method would save back that far)
04-11-2014 01:37 PM
Hi Jeff,
How can you get the copy of kGlobal sign ?
Thanks,
KN
04-11-2014 01:49 PM
A static VI reference constant is available in the functions palettes Programing>Application control. Drop it on your BD. Rightclick and browse for the global or drag the globals icon into the reference.
I assume you tried creating a constant from the invoke node. That will create a strict static reference and you won't be able to drop a global into that.
04-11-2014 02:45 PM
Hi Jeff,
Thank you very much for your help. It's working for me.
KN
04-11-2014 05:55 PM - edited 04-11-2014 05:57 PM
I don't have a development environment available right now, so I can't try it out - but I believe that the Global Variable Front Panel will be removed from compiled code and may not function as you expect it to.
I appreciate you are learning how to use Globals Variables, but I will just add that I very rarely use them. There are several much safer tools available for sharing data between threads