LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

"Value changed" Event.

Hi,

I have a string control and a "Value Changed" - event connected to it. So, when I change the string this Event should fire and a function should be called. (A calibration function of some instruments are started).

So, this works great... almost...

If my string control has string "abc123" and I load a string from file into that string control with the string "abc123" - LabVIEW considers this as "Value Changed" and calls my Event handler even though the value is the same in both cases.

I have tried to make my own "Event" by copying the string to an "Old string" and then comparing the new and old string to see if is it changed by the result is exactly the same.

Any ideas are welcome, thanks.

/Thomas
0 Kudos
Message 1 of 8
(3,862 Views)
I was also a bit surprised how this works. Apparently any entry counts as a "Value Changed". Looks like you'll have to do a compare. The event handler has the OldVal and NewVal on the left side for easy access. See the attached.

Good luck.
Tim
0 Kudos
Message 2 of 8
(3,862 Views)
....
> I have tried to make my own "Event" by copying the string to an "Old
> string" and then comparing the new and old string to see if is it
> changed by the result is exactly the same.
>

If you do need to compare the data, the event structure terminals on the
left side havs both the new and old values available.

Greg McKaskle
0 Kudos
Message 3 of 8
(3,862 Views)
I am surprised that LabVIEW fires a "value changed" event programmatically. I tried, but failed to duplicate your problem, because it had the potential
to be useful for my application...

I put an event structure which captured "value change" events for a string control in one while loop,
and created a parallel while loop to capture events on a "load" boolean. The load boolean value changed event triggered loading a string from a file, and writing it into the string control.

When I ran the VI, and pressed "Load", the value from the file appeared in the string control, but no event fired.

What is different between my scenario and yours? Is there some LabVIEW config file option that allows you to fire events programmatically, while I am only able to fire
them through directly-user-interface triggered actions?
0 Kudos
Message 4 of 8
(3,862 Views)
Isaak,

Your scenario is a good example of how event structures do and don't work. The event is not triggered by a programatic change - which is done when you press your "Load" button. The event is triggered only if you change the contents of the string control on the front panel.

What is interesting is that if you type "test" into your string control, then replace it with "test" (identical string) it recognizes this as a change. I believe this is what Thomas' original question was.

Tim
0 Kudos
Message 5 of 8
(3,862 Views)
Isaak,
Oops, just re-read the original question. You are exactly correct. It should not repsond to programatically changing the string - as your example shows.

I guess I should follow the old adage "read twice, respond once". My apologies.
Tim
0 Kudos
Message 6 of 8
(3,862 Views)
Then I guess we are in agreement that we don't know how the original post can be entirely correct:

"If my string control has string "abc123" and I load a string from file into that string control with the string "abc123" - LabVIEW considers this as "Value Changed" and calls my Event handler even though the value is the same in both cases."

If you can trigger an event of any kind by "loading a string from file into that string control", I'd love to see an example!

The original poster probably meant "when I type the same string in, or when I cut-and-paste it in". By "load it in" I thought the VI was loading the information from a file, and that maybe there was some special behavior for the event structure if a disk access had just occ
urred in that thread... or soomething really silly like that.
0 Kudos
Message 7 of 8
(3,862 Views)
Please note that the above response was written before the advent of LabVIEW 7. With Version 7, it is now straight-forward to fire events programmatically by either writing a value to the "Value(Signalling)" property, or using the Send Event vi.
0 Kudos
Message 8 of 8
(3,862 Views)