LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can a tab dialog get its contents from an enum?

Suppose you've got a simple enumeration of states ("Login", "Measure", "Save", "Logout").

You'd like to define that enum in one place and then use it as states in a state machine to keep track of what point in the process your program is in. You'd also like to use the same list of states for the pages in a tab dialog.

Now, in the world of reusable software, you'd like it if you could have the list of states defined in one place, and when you change it, it automatically updates the case statement for your state machine AND automatically adds/deletes/changes the pages on your tabs. Even if it wasn't 100% automatic, you'd at least like it to be a click on "update this object" or something, as opposed
to opening each object and changing the states that appear in a completely manual way.

As far as I can tell, I can't wire an enum to a tab control in any way. Is there a way to propagate the contents of an enum to a tab control?

The more I use LabVIEW the more I realize that resuse simply is not a real option, and this is a great tool for the quick&dirty but a terrible tool for anything that might evolve or modify over time.
0 Kudos
Message 1 of 7
(3,341 Views)
I agree with you on the defines. It's very useful to have all your variables defined in one location and updated as you go along.

What I end up doing in this case is to use global variables. Though, it is not the most elegant way, it works well.

Even with LabVIEW's limitations, I think you can write a relatively "modular" code that you can reuse when necessary.

I'm not sure if I understand what you meant by "I can't wire an enum to a tab control in any way. Is there a way to propagate the contents of an enum to a tab control?"

As far as I know, a tab control is an enum control. You'd wire the tab control into a case statement.

Please clarify on what you want to do so we can help you further.

Shan Pin Koh
0 Kudos
Message 2 of 7
(3,341 Views)
What I mean is that I need to define a list of states someplace, probably as an enum.

Then later I have a state-machine case statement that has this enum wired to it. I also have a tab control that should have the same exact states in it, but to do this I have to create a tab control, and then manually insert each state. Then, next week when I change the list of states slightly I have to change it in two places to keep things synchronized.

When I wire that enum to a case statement, the case statement changes itself to have one case for each value in the enum. I'd like to do the same thing for a tab control, ie, use an existing enum to tell the tab control what pages it should have. If the tab control "Pages" property wasn't just a read-only property I cou
ld do this programmatically, but I guess a fundamental LabVIEW problem is inability to programmatically create controls/indicators.
0 Kudos
Message 3 of 7
(3,341 Views)
I guess you are right. It's a little more tedious for what you're planning on doing.

I tried creating an application like how you described it using a global variable and CASE statement. I can have all the necessary CASE statement synchronized, not automatically but rather programmatically. What I can't do is to get a tab control indicator to synchronize.

I'm sorry but I guess this is another LabVIEW drawback.

Shan Pin Koh
0 Kudos
Message 4 of 7
(3,341 Views)
I don't think the inability to change a tab control's properties has anything to do with programatically creating controls or indicators. The tab control is new in LabVIEW 6 and judging by the number of comments made in this forum and on info-labview, there are a lot of users that have requested changes to its behavior and my guess is that you'll see them in the next revision of LabVIEW (6.1?). In the meantime, instead of using the LabVIEW tab control, you could use an ActiveX control that does have the ability to programatically add tabs or change the tab text. And if you're really interested in code re-use issues, get involved in the Object Oriented Programming in LabVIEW discussion and look at what's being done now and what might be done in th
e future.
0 Kudos
Message 6 of 7
(3,341 Views)
It is tricky but you can have the enum to get its strings from the tab
strings.

Run the attached "TabtoEnum.vi" first to get the tab strings. Since the tab
control do not
have a Strings[] property like the menu enum, you have to get them on the
diagram where
the tab control resides.
Second you run SetEnumStrings.vi to change the enum Strings[]. Since
changing enum strings is edtiting stuff, the VI where the enum is located
must not be running.

Jean-Pierre Drolet



"Bmarsh" a écrit dans le message news:
5065000000080000000E240000-993342863000@exchange.ni.com...
> Suppose you've got a simple enumeration of states ("Login", "Measure",
> "Save", "Logout").
>
> You'd like to define that enum in one place and then use it as states
> in a stat
e machine to keep track of what point in the process your
> program is in. You'd also like to use the same list of states for the
> pages in a tab dialog.
>
> Now, in the world of reusable software, you'd like it if you could
> have the list of states defined in one place, and when you change it,
> it automatically updates the case statement for your state machine AND
> automatically adds/deletes/changes the pages on your tabs. Even if it
> wasn't 100% automatic, you'd at least like it to be a click on "update
> this object" or something, as opposed to opening each object and
> changing the states that appear in a completely manual way.
>
> As far as I can tell, I can't wire an enum to a tab control in any
> way. Is there a way to propagate the contents of an enum to a tab
> control?
>
> The more I use LabVIEW the more I realize that resuse simply is not a
> real option, and this is a great tool for the quick&dirty but a
> terrible tool for anything that might evolve or modify over
time.



[Attachment SetEnumString.vi, see below]


[Attachment TabToEnum.vi, see below]


LabVIEW, C'est LabVIEW

Download All
0 Kudos
Message 5 of 7
(3,341 Views)
you CAN wire an enum to a tab.
1-on the Diagram panel, right click the tab control and choose to change it to indicator.
2-wire the tab control to the indicator.


now: do you know how to use a certain part on multiple layers of a tab without having to recreate the part ( that is, the part only has on icon representing it on the diagram panel)?
0 Kudos
Message 7 of 7
(3,341 Views)