LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Possibility to Use Enum Control as index input for For Loop

Solved!
Go to solution

Hi everyone,

 

I am curious that whether an ENUM type could be an index input for a For Loop (actually i tried in labview but it was NOT working).  

 

I use Enum for my two configurations(only two elements there), but some times I need to run both of them together. 

 

I am wondering if there is some good structure to handle that or I just replace ENUM with array.

 

 

Thanks,

 

-Kunsheng

Message Edited by Kunsheng Chen on 04-07-2009 01:33 PM
0 Kudos
Message 1 of 11
(16,443 Views)

Kunsheng,

 

The "value" of a ENUM is a unsigned 16bit integer that represents the current index of that control (as viewed by right clicking the ENUM and selecting "Edit Items..." ) 

 

There are several ways to use this value to then control the FOR loop. One simple solution would be to wire the ENUM to a Case structure - the cases can then define what you want your For loop to do.

 

You can also use property nodes, array indexing, etc. to accomplish similar results.

 

Have Fun!

 

Message Edited by Jolt on 04-07-2009 01:42 PM
Message 2 of 11
(16,433 Views)
Solution
Accepted by topic author Kunsheng Chen

Here is an example using property nodes:

 


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Message Edited by jmcbee on 04-07-2009 12:53 PM
0 Kudos
Message 3 of 11
(16,424 Views)
Message Edited by jcarmody on 04-07-2009 07:02 PM
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 4 of 11
(16,394 Views)
Thanks for all you guys! I will do it tomorrow.
0 Kudos
Message 5 of 11
(16,382 Views)

Check out this post for a way to do it without using property nodes. Property nodes cause LabVIEW to swap to the User Interface thread and generally slow you down, so avoid them when you can. This method also allows you to use an enum constant instead of a control.

 

 

Jarrod S.
National Instruments
Message 6 of 11
(16,318 Views)
That is a very nice solution.  What other fun things do you guys have tucked away in the vi.lib?
0 Kudos
Message 7 of 11
(16,314 Views)

Awesome! I played a little bit with property node today. Got a feeling of windows forms programming in .NET,  u play around all attributes of certain control there.

 

0 Kudos
Message 8 of 11
(16,300 Views)

Jarrod S. wrote:

Check out this post for a way to do it without using property nodes. Property nodes cause LabVIEW to swap to the User Interface thread and generally slow you down, so avoid them when you can. This method also allows you to use an enum constant instead of a control.

 

 


 

Lava seems to have changed the indexing of their messages.  By any chance, could you relink your message to the post you referred to?

 

thanks,

Ron

Message Edited by mysticfree on 05-25-2010 11:13 AM
0 Kudos
Message 9 of 11
(15,809 Views)

Here is a code snippet of itterating over each intem in an enum list, no property nodes needed. 

It uses the flatten to string (the enum length is at index 2 of the header)

Change the enum and the code will automatically execute add it to the list of things to do, like a for each structure

 

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 10 of 11
(15,768 Views)