LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Global Array not updating

Solved!
Go to solution

Dear users,

I have the following structure :

image.png

Relay card table is an array of clusters. What I am trying to do is to address one of the objects in cluster, change its property "status" to true, and put it back in the array. However, it does not seem to work. When I probe the cluster object after "status", it shows that it indeed has changed the status, and yet, the global variable does not reflect this. Any ideas why?

0 Kudos
Message 1 of 5
(3,612 Views)
Solution
Accepted by topic author Atizss

Hi Atizss,

 

What I am trying to do is to address one of the objects in cluster, change its property "status" to true, and put it back in the array.

That's what your code should do…

 

However, it does not seem to work. When I probe the cluster object after "status", it shows that it indeed has changed the status, and yet, the global variable does not reflect this. Any ideas why?

When you probe the wire after the Bundle function you didn't change the global variable so far. The global should change after the ReplaceArray function!

 

The problem with your code is its vulnerability for Race conditions as soon as you access that global in parallel with several instances. You better use a functional global (or other means) to implement some data capsulation!

(Possible Race condition: Why do you need to read that global variable twice in this little code snippet?)

Best regards,
GerdW


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

Besides, it wastes a lot of memory (all reading variables are copies)....

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 3 of 5
(3,594 Views)

@Norbert_B wrote:

Besides, it wastes a lot of memory (all reading variables are copies)....


I've read that is the case for Local Variables, but i'm not sure about the Global scenario.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 5
(3,574 Views)

Besides, it wastes a lot of memory (all reading variables are copies)

As stated, this is true for ALL reading variables native in LV. Where i'm not sure are the network published shared variables as they are hosted externally to LV (Shared Variable Engine). It's possible that these don't create copies but protect the access. At least this might be a good explanation why they are way slower than the other ones....

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 5 of 5
(3,559 Views)