04-01-2019 03:42 AM - edited 04-01-2019 03:45 AM
Dear users,
I have the following structure :
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?
Solved! Go to Solution.
04-01-2019 03:57 AM - edited 04-01-2019 04:00 AM
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?)
04-01-2019 04:21 AM
Besides, it wastes a lot of memory (all reading variables are copies)....
04-01-2019 04:56 AM
@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
04-01-2019 06:37 AM
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....