10-27-2011 09:23 PM
Dear All,
I was previously from code based programming.
Can you show me what can I do to trigger a Button(B1) value change event by another Button(B2) event?
Thank you
10-28-2011 12:49 AM
Hi Vincent,
Kindly check the attached VI. It may help you.
Regards,
NitzZ
(Give kudos to good Answers, Mark it as a Solution if your problem is Solved;))
10-28-2011 01:33 AM
Nitz showed you in the example how to do it. LabVIEW front panel controls have all a "Value(Signalling)" property you can use to modify the value of a control AND cause an according event to be triggered, if the control is registered for an event. It's in my humble opinion one of the only two valid cases where the Value property should be used at all. The other is for initialization of front panels. Any other use of the Value property I consider abuse.
08-20-2015 10:09 AM
Remember your sequence of events in Labview is different from procedural programming.
In a procedural language you would press Button2 and inside that handler call the Button1 handler and run the Button1 code. After the Button1 code completes you would return and finish the rest of the Button2 logic.
So something like :
Button2_Handler()
{
// Start running Button2 stuff
// Call Button1 logic and perform all of Button1 stuff
Button1_Handler();
// Finish Button2 stuff
}
Button1_Handler()
{
// Do Button 1 stuff
}
In Labview you press Button2 and inside that handler you make the request for Button1 to be run, finish the Button2 handler, and then the Button1 handler will be called.
In a procedural language this would look something like :
Button2_Handler()
{
// Start running Button2 stuff
// Request Button1 logic to be performed but don't run it yet
runButton1Handler = true;
// Finish Button2 stuff
}
Then inside some polling routine:
while(true)
{
if(runButton1Handler == true)
{
Button1_Handler()
{
// Do Button 1 stuff
}
// Clear button 1 logic flag so it doesn't keep running inside poll routine
runButton1Handler = false;
}
}
This was tricky for me to learn since I also came from a procedural background.
08-20-2015 12:12 PM
Another caveat -- Button 1 (the one you want to use with Value (Signal) property) cannot have a Latch mechanical action. If you try to programmatically set the value of a Latched Boolean, you will get either a Compile Time (= Broken Arrow) or Run Time (= Error Message) error.
Bob Schor
08-20-2015 12:29 PM
@Bob_Schor wrote:
Another caveat -- Button 1 (the one you want to use with Value (Signal) property) cannot have a Latch mechanical action.
That's where this idea would help. 😄