Jump to content

Programmatic value change event handling


Recommended Posts

Hi all,

Recently upgraded from Base to Professional. Replacing some of my polling While Loops with these 'new' (to me, and therein lies the problem perhaps) Event Structures, but have become a bit perplexed.

A top level VI contains some numeric/string/path controls. These control values are checked for validity (file/dirctory exists, for example) whenever the user changes their value, before they're passed on. Okay so far. Event Structure fires as a result of the change and executes the relevant code. However, I wish to do the following:

I want to check the control values at top level first run (they may have been valid once but not now). No value changes of course, so no events fire, so nothing happens/is checked.

The user can set the control values from file. I would like to check the values after that.

The user can set the control values to their default. I would like to check the values after that.

The latter two cases I thought might cause the events to fire, but of course I now know that the Event Structure responds only to GUI changes, not programmatic ones. I know this because a colleague pointed me towards the Val(Sgnl) property node. This seems the way forward, but how to implement it 'best practice' I'm not sure.

It seems to me, for every situation where I want to check control values that have changed (maybe) programmatically, I must wire their Val property to their Val(Sgnl) property to fool the Event case(s) into thinking there has been a value change, even though there might not have been! Fortunately, all my controls are in clusters, and there are not many clusters, so this wouldn't be too onerous.

I attach a VI that does do what I want. My problem is that this method seems very untidy and clunky, particularly as no value changes may have occurred at all, rather defeating the point of the Event Structure. I can't help feeling that there must be a slicker way of doing what I want. Tell me I've missed the option on an Event Structure pop-up that says "respond to value changes however occured and at first run" :thumbup: . Alternatively, tell me I'm barking up the wrong tree completely :( . Any ideas, anyone?

Regards, Graeme.

Link to comment

QUOTE(Graeme @ Aug 17 2007, 11:00 PM)

Hi all,

Recently upgraded from Base to Professional. Replacing some of my polling While Loops with these 'new' (to me, and therein lies the problem perhaps) Event Structures, but have become a bit perplexed.

A top level VI contains some numeric/string/path controls. These control values are checked for validity (file/dirctory exists, for example) whenever the user changes their value, before they're passed on. Okay so far. Event Structure fires as a result of the change and executes the relevant code. However, I wish to do the following:

I want to check the control values at top level first run (they may have been valid once but not now). No value changes of course, so no events fire, so nothing happens/is checked.

The user can set the control values from file. I would like to check the values after that.

The user can set the control values to their default. I would like to check the values after that.

The latter two cases I thought might cause the events to fire, but of course I now know that the Event Structure responds only to GUI changes, not programmatic ones. I know this because a colleague pointed me towards the Val(Sgnl) property node. This seems the way forward, but how to implement it 'best practice' I'm not sure.

It seems to me, for every situation where I want to check control values that have changed (maybe) programmatically, I must wire their Val property to their Val(Sgnl) property to fool the Event case(s) into thinking there has been a value change, even though there might not have been! Fortunately, all my controls are in clusters, and there are not many clusters, so this wouldn't be too onerous.

I attach a VI that does do what I want. My problem is that this method seems very untidy and clunky, particularly as no value changes may have occurred at all, rather defeating the point of the Event Structure. I can't help feeling that there must be a slicker way of doing what I want. Tell me I've missed the option on an Event Structure pop-up that says "respond to value changes however occured and at first run" :thumbup: . Alternatively, tell me I'm barking up the wrong tree completely :( . Any ideas, anyone?

Regards, Graeme.

While Im not really up to speed on change signal events If they do actually work Id see no issue with using

that approach for small to medium complexity tests.

BTW theres nothing wrong in my book to firing (even false) events if the end result is validated input.

I cant say if its the preferred way to do it however..

Link to comment

Your approach seems good, just remember you have 3 different 'events'

  1. Initialize
  2. Load From file
  3. User edit

You could use one 'user event' to handle all these events, or a subvi which takes in the 'new' value and the controls name, does a check on it based on ..... (fill in your method) and outputs a valid value.

Ton

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.