LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Button and tab

Solved!
Go to solution

I have two questions for my .vi

 

1. I need same button to shown in more tabs(not just on one...). For example in my .vi I have button on first page, I would like to have same button also on page 2. How can I do that?

 

2.  Which property and how can I use to do the next thing:

      For example I have value "up" and "down". When I pressed some button I would like that this two values will automatically replace each other.  Also labels must be replaced.

_________________________
Rookie; LV 2011 on WIN 7
0 Kudos
Message 1 of 10
(3,978 Views)

@hlod wrote:

I have two questions for my .vi

 

1. I need same button to shown in more tabs(not just on one...). For example in my .vi I have button on first page, I would like to have same button also on page 2. How can I do that?


This question has been asked dozens of times. Please perform a search before posting. Put the button on the front panel and move it over the tab using the cursor keys.

 


2.  Which property and how can I use to do the next thing:

      For example I have value "up" and "down". When I pressed some button I would like that this two values will automatically replace each other.  Also labels must be replaced.


This has also been asked before dozens of times. Please perform a search before posting. Use the Boolean Text property.

Message 2 of 10
(3,966 Views)

hlod wrote:

1. I need same button to shown in more tabs(not just on one...). For example in my .vi I have button on first page, I would like to have same button also on page 2. How can I do that?


Saverio already pointed out a solution for the case where the controls should appear on all tab pages. Your question is not specific enough to tell if you actually want that or if the control should show on more than one, but not necessarily all pages. Please be more specific.

Typically if a button should be visible on all tabs, it probably belongs outside the tab structure.


@hlod wrote:

2.  Which property and how can I use to do the next thing:

      For example I have value "up" and "down". When I pressed some button I would like that this two values will automatically replace each other.  Also labels must be replaced.


Please clarify what you mean by value for "up" and "down".

  • What is the datatype that has these values? Booleans? enums? Strings?
  • Are these controls or indicators?
  • What is "replace each other"? Should they both be visible, but swap their label or place? Should only one or the other be visible? What is the current label and what do you want to replace it with? Please be much more specific and include it in you example code. Your current attachment has nothing resembling even remotely anything that could be considered "up" or "down"... ;).
  • Sometimes you can use a single button with one state having a boolean text of "up" and the other state "down". Changing the value would switch between the two. It is not clear if it would be appropriate for your problem because we don't understand your problem yet.

 

 

 

Message 3 of 10
(3,960 Views)
Spoiler
Put the button on the front panel and move it over the tab using the cursor keys.

 I don't know what you mean wtih cursor keys... My control must be shown on 2 tabs, but not on third one. I cannot put it outside of tabs, please understand this.

 

 

Spoiler
hlod wrote:

2.  Which property and how can I use to do the next thing:

      For example I have value "up" and "down". When I pressed some button I would like that this two values will automatically replace each other.  Also labels must be replaced.


Please clarify what you mean by value for "up" and "down".

  • What is the datatype that has these values? Booleans? enums? Strings?
  • Are these controls or indicators?
  • What is "replace each other"? Should they both be visible, but swap their label or place? Should only one or the other be visible? What is the current label and what do you want to replace it with? Please be much more specific and include it in you example code. Your current attachment has nothing resembling even remotely anything that could be considered "up" or "down"... :manwink:.
  • Sometimes you can use a single button with one state having a boolean text of "up" and the other state "down". Changing the value would switch between the two. It is not clear if it would be appropriate for your problem because we don't understand your problem yet.

- datatype: DBL (double) -64 bit real

- controls !

-yes both must be visible, just swap their label and values( value 4.5444  from "up"   become "down" value, and value from down become value up; same for label) ; location must be same as previous; Alyways both of them must be visible.

 

 

 

 

 

_________________________
Rookie; LV 2011 on WIN 7
0 Kudos
Message 4 of 10
(3,957 Views)

Still searching solution for both question;

 

For first one I tried this several times:

"Move it (using the mouse) outside of the tab, then move it (using cursor keys!) over the tab control. Now the button is on top (or can be made so with the order button in the menu) and is visible in each tab page..."

 

But when I move button outside of tab, my cursor keys have no control(nothing happend). I have LV 2011

_________________________
Rookie; LV 2011 on WIN 7
0 Kudos
Message 5 of 10
(3,941 Views)

I done something, but it's not working as I want. When I turn on "highlight execution", it's working as I want, but if I normally run, not. 

 

I want that when I pressed button, UP, becom DOWN (caption and value), when button is on OFF, must be reseted all back to original!

 

Please see attachments .vi

_________________________
Rookie; LV 2011 on WIN 7
0 Kudos
Message 6 of 10
(3,927 Views)
You've got a classic race condition. You might want to review some of the LabVIEW tutorials to get a better understanding of data flow.

Why don't you simply swap position of the two controls? It seems you are just making things much more complicated.

And why haven't you moved the stop button? Select it and move it with the cursor keys as already explained.

p.s. You should really learn to use the event structure.
0 Kudos
Message 7 of 10
(3,913 Views)

I don't understand what you are doing anymore, since you are now apparently changing the captions of numeric controls. I also know how to spot a race condition, and that is what you have in your VI. You are writing to a control and reading from it, but you cannot know for certain whether the read or write will occur first. The way it's written, it's likely that the read from "Up" will occur before the write, but that is not 100% certain.

 

As for the Boolean Text, just change it on the control itself. Right-click on the Boolean and select Visible Items -> Boolean Text. Then change the text that's shown for when the Boolean is true, and what's shown for when it's false.

 

As for moving the button over the tab control, I do not understand what you mean by the cursor keys "not having control". You also said that you want the control over two tabs, but not the third. If this is the case, you can:

  • Use different buttons, and use a single event case in the event structure for all of them.
  • Use one button, and simply make it invisible when the third tab is shown.
Message 8 of 10
(3,912 Views)

@hlod wrote:

When I turn on "highlight execution", it's working as I want, but if I normally run, not. 


This behavior ALWAYS points to a race condition. In your particular case, you are copying value and caption from each control to the other control in parallel. There is no data dependecy between the two code segments so you can have many possible scenarios with random outcome, depending on the order things happen:

 

  1. read down, read up, write down, write up (OK)
  2. read down, write up, read up, write down (both controls will have the "down" value)
  3. read up, write down, read down, write up (both controls will have the "up" value)
  4. etc...

Also, your button is set to switch action, meaning as long as it is true, the value and labels will bounce back and forth 10 times per second. You need to ensure that the property nodes execute only once after the button has been pressed. The code needs to execute if the button goes true->false or false->true.

 

Message 9 of 10
(3,911 Views)
Solution
Accepted by topic author hlod

Here's a quick draft how you could enforce execution order using an error wire.

 

(But I agree that there are probably much better ways to do all this. It is usually not recommended to warp the UI, because it confuses the user and leads to inconsitent user experience.)

Message 10 of 10
(3,907 Views)