From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I Register a Global Variable Object Value Change in an Event structure?

Solved!
Go to solution
Sigh...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 11 of 20
(1,212 Views)

OK.

 

I was not trying to convert you, only answer your question.

 

take care,

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 12 of 20
(1,211 Views)

You may think you have everything safeguarded but along comes the next developer who uses it in ways you didn't intend and then your whole system goes to hell.

 

You are absolutely right.  But excellent programming style won't save you from another developer.

 

I didn't wish this to be a discussion about the merits of global variables.  I understand their pitfalls and use them when I feel appropriate.  My point is that there are times when they don't destroy your code.

 

 

This was a thread asking about one technical aspect (getting them to trigger an event structure), and my suspicion is that this will not work.

0 Kudos
Message 13 of 20
(1,210 Views)

And I appreciate that Ben.  😉

0 Kudos
Message 14 of 20
(1,207 Views)

@Jed Davidow wrote:

You may think you have everything safeguarded but along comes the next developer who uses it in ways you didn't intend and then your whole system goes to hell.

 

You are absolutely right.  But excellent programming style won't save you from another developer.

 

I didn't wish this to be a discussion about the merits of global variables.  I understand their pitfalls and use them when I feel appropriate.  My point is that there are times when they don't destroy your code.

 

 

This was a thread asking about one technical aspect (getting them to trigger an event structure), and my suspicion is that this will not work.


 

[Set mode = broken record]

 

An AE could esily be updated to fire a User Event when a value changes.

 

Ben

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 15 of 20
(1,204 Views)

[Set mode = broken record]

 

An AE could esily be updated to fire a User Event when a value changes.

 

Ben

Broken record?  This is why I just looooove asking questions in the forums....

 

 

Question: Is it possible to do A to B?

 

Answer:  You should not use B.

 

Q: Got it. Thank you for your opintion and excellent argument.  I appreciate it.  Here are my thoughts on that subject.

 

Q: But still, Can I do A to B?

 

Answer: Condescending Sigh.  You are an idiot for using B in the first place.

 

Q: Possibly so, but I would just like an answer to my question without being insulted.

 

Answer:  Sorry.  No answer to your question, but we will just keep insulting you.

 

Q: Thanks.  You've been very helpful, reminding me of information I already knew and implying that I am an idiot ("Sigh", "Broken Record") for seeking an answer to another question entirely.


Q: And by the way, original question still not answered. 

0 Kudos
Message 16 of 20
(1,201 Views)

the broekn record switch applied to myself since I am often pushing AEs.

 

Please accept my appology if it came across as directed at you.

 

Re: Original Q

 

I don't think it possible to fire an event on a global change. If the global is replaced with an AE we can fire a user event or submit an entry yo a queue.

 

An even could be registered for the GUi control (like Mike mentioned) and using dynamic events will let you trigger code in one VI when a control in another GUI changes.

 

I also belive that in DSC an event can be registered for a SV change but I think that required DSC.

 

I usspect there are other options as well but for a global, no.

 

I hope that clears it up a bit.

 

Trying to help,

 

Ben

 

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 17 of 20
(1,197 Views)

Thank you, Ben.

 

I use AEs all the time (I am going to be evangelical with that name).  But I also use GVs where I think they are simple and appropriate.

 

Normally I have a save/cancel button on my code.  I was thinking in this case it made more sense to just save the config every time a change was made.  Doesn't look like it's that simple.  AEs would solve this problem, but as there are about 20 values of varying types to deal with, I think that coding all those AEs would take up a considerable amount of the 10 hours I am being paid for to do this as a favor for a friend who thought he could learn LV in an afternoon 😉

Message 18 of 20
(1,192 Views)

Good!

 

I am glad we cleared that up.

 

Here take a Kudos for not giving up on me!

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 19 of 20
(1,190 Views)
Solution
Accepted by topic author Jed_Davidow

@Jed Davidow wrote:

 

As for this specific applicaiton (and this is almost exclusively where I use them), I like them for my configuration...

 

1) I use the OpenG Write Panel to Config and Read Panel from Config to populate/save the configuration.

2) Depending on the complexity and nature of the code, I will use a sub-panel to embed the global panel in the app.  This allows the user to directly change the settings (Works great in simple situations, not great when the code has to be interactive here or contain code-assisted elements (tables, trees)).

3) A VI-panel could be used, yes (and this would allow for more complex interaction).  But accessing each of those values would require another level of code.

 



I looked into going down that road some years back for exactly the same reason you are, but quickly dropped it (not because of the problems with globals, but mainly because you can't create a custom UI when you need to, as you've also found out).

 

In my test, I didn't bother with getting events - a simple loop with a wait was enough and you simply save the values once on exit (but that, for instance, doesn't allow cancelling the changes. For that, you would need to read the values on start and restore them on cancel).


___________________
Try to take over the world!
Message 20 of 20
(1,181 Views)