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.
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.
03-16-2012 11:38 AM
03-16-2012 11:40 AM
OK.
I was not trying to convert you, only answer your question.
take care,
Ben
03-16-2012 11:41 AM
> 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.
03-16-2012 11:42 AM
And I appreciate that Ben. 😉
03-16-2012 11:45 AM
@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
03-16-2012 11:58 AM
[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.
03-16-2012 12:04 PM
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
03-16-2012 12:27 PM
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 😉
03-16-2012 12:32 PM
Good!
I am glad we cleared that up.
Here take a Kudos for not giving up on me!
Ben
03-17-2012 12:18 PM
@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).