LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What he heck with those buttons !

How can I make that a buttons becomes back popped-out after a certain
command ?
I have a switch between measurement and test-function.
When I put it in test. The test performs, but after that is must be back
in the measurement position.

Thanx !!

Kristof
0 Kudos
Message 1 of 9
(3,752 Views)
Right click on the control. Select Mechanical Action>Latch When Released. The button will return to the false state once it is read.
0 Kudos
Message 2 of 9
(3,752 Views)
Dennis is, of course, correct. And we all know local variables are sloppy coding. I would not use 'latch when...' way for situations where it is CRITICAL the code only executes once. This is mainly for re-use reasons. If i need to go back 6 months or a year from now, or if someone else takes over my code, it is clear that the code must reset the switch as soon as this case executes. Looking at my code should tell others they shouldn't switch to the other 'switch when...' modes. This might not be clear using the 'Latch when...' modes.

There is always more than 1 way to skin a cat (or write code)!!

Jared
0 Kudos
Message 6 of 9
(3,752 Views)
I don't get this. If a switch is set to "latch" then it will only be true
once, then it pops back out. For critical purposes and code re-use this is
better to my mind than using locals. You can not have a local of a switch
set to latch; it can only be read at one point in the code and it will only
be true once. Using locals does not increase reliability- it decreases it.

If you're using locals then it's not clear from looking at the code that
there isn't a local somewhere else that can do something, and you can create
as many more locals in as many places as you like on subsequently editing
poorly understood code. If you have a switch set to latch and you create a
local it's very obvious what's happened because the VI immediately breaks.

Certainly
it *works* either way- as you say there's always more than one
way. I just don't understand your reasoning here.

Jared wrote in message
news:101-5065000000050000005A190000-982303670000@quiq.com...
> Dennis is, of course, correct. And we all know local variables are
> sloppy coding. I would not use 'latch when...' way for situations
> where it is CRITICAL the code only executes once. This is mainly for
> re-use reasons. If i need to go back 6 months or a year from now, or
> if someone else takes over my code, it is clear that the code must
> reset the switch as soon as this case executes. Looking at my code
> should tell others they shouldn't switch to the other 'switch when...'
> modes. This might not be clear using the 'Latch when...' modes.
>
> There is always more than 1 way to skin a cat (or write code)!!
>
> Jared
0 Kudos
Message 7 of 9
(3,752 Views)
Craig said : "If you're using locals then it's not clear from looking at the code that
there isn't a local somewhere else that can do something, and you can create
as many more locals in as many places as you like on subsequently editing
poorly understood code."

Because that's not the way i would do it. I use this local method in only 1 place. I see a switch to a case and the true case has a local of the same switch turning it off, i understand what i;m trying to do (stop me from using other 'switch when...' cases). I don't use it in other cases. I dont put locals all over the place. I've only used this method a couple of times for 'mission critical' situations and know what it means when i see it in my code. I'm assuming here the 'other
' people who would pick up my code and use it when i'm gone are going to see things the same way i do. I know that may not be the case and i'm glad to hear others' opinions. I do appreciate your input.

Jared
0 Kudos
Message 8 of 9
(3,752 Views)
Kristof,

you need to play with the mechanical action of the switch. Right click on the switch and point at 'mechanical action'. There are several possibilities that will work for you. The one i like the best for your type of situation is 'switch when pressed' and inside the 'test' case wire the oppisite state into a local variable for the switch.

Actions like 'switch until released' or 'switch when released' will work too, but the loop must be checking the state of the switch at that time. This may look buggy if other operations are taking place and the user presses the button quickly. The button will go in and out and your code won't execute.

hope this helps,
Jared
Message 3 of 9
(3,752 Views)
Kristof Poppe wrote:
>How can I make that a buttons becomes back popped-out after a certain>command
?>I have a switch between measurement and test-function.>When I put it in
test. The test performs, but after that is must be back>in the measurement
position.>>Thanx !!>>Kristof>>

Kristof,

you can right click on the button and create a local variable. after test
performs, wire the local variable false (or true depending how you have it
setup).

pat
0 Kudos
Message 4 of 9
(3,752 Views)
Hi,

you can do that by choosing latch from "mechanical action". Just right
click on the button and choose "mechanical action", then choose one of
the latch functions. Alternatively you can do it programatically by
invert the current state of your button.

chris

Kristof Poppe wrote:
>
> How can I make that a buttons becomes back popped-out after a certain
> command ?
> I have a switch between measurement and test-function.
> When I put it in test. The test performs, but after that is must be back
> in the measurement position.
>
> Thanx !!
>
> Kristof
0 Kudos
Message 5 of 9
(3,752 Views)
Thanx for all the tips. The mechanical action - thing I doscovered later, but
that wasn't what I was looking for. But the solution with the local variable
works !

Thankx !!

chris wrote:

> Hi,
>
> you can do that by choosing latch from "mechanical action". Just right
> click on the button and choose "mechanical action", then choose one of
> the latch functions. Alternatively you can do it programatically by
> invert the current state of your button.
>
> chris
>
> Kristof Poppe wrote:
> >
> > How can I make that a buttons becomes back popped-out after a certain
> > command ?
> > I have a switch between measurement and test-function.
> > When I put it in test. The test performs, but after that is must be back
> > in the measurement position.
> >
> > Thanx
!!
> >
> > Kristof
0 Kudos
Message 9 of 9
(3,752 Views)