LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

global variable not working after compile

Two VIs running perfectly before compile. As the example app Generate Numbers and Display Numbers shown in NI's library, the two VI runs; reads and writes as expected...

 

I tried to include the gv in the "Startup VIs" in both VIs when "build" and I can see gv works in parallel with Generate Numbers executiable and if run the non-compiled vi Display Numbers and see the numbers get through. But a compiled "Display Numbers" vi (or executiable) will not "read" the numbers through the gv.

 

Did i miss anything when compiling or the gv is not supposed to be used in this situation. I know I can use shared variables for the same purposes but what is wrong? 

0 Kudos
Message 1 of 5
(2,994 Views)

Are you saying you have two different executables (one for each VI)?

 

Global do not have a scope beyond the instance they are running in.  So two different executables are each running in their own instance and a globabl variable will not jump between them.  When you run both VI's in the raw development environment, the global will work because both VI's and the globabl are all living in the same instance of the LabVIEW development environment.

 

If you need to share data between different executables, then you should use shared variables.

0 Kudos
Message 2 of 5
(2,991 Views)

I guess I was confused by the two VIs talking through a GV. I thought the GV might be a piece of shared memory. So what's the point of the examples NI showing us using GV?

0 Kudos
Message 3 of 5
(2,989 Views)

Hi Tian,

 

the point of a GV is to share values between (sub)VIs of one project or (after compilation) one executable.

It's the same in other programming languages: when you write a C program using a global variable that variable is only accessable by the functions of that single program/executable.

 

To share data between executables you have to use files or network (like SharedVariables)!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 5
(2,986 Views)

one executiable is the key. Using a shift registered cluster would pass the same data among sub-vis. GV would hide these away. I got it. I am now using SV instead. Thank you very much!  

0 Kudos
Message 5 of 5
(2,982 Views)