LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

progmatically populate enum and case structure

Hi,

 

New to labview and have an issue with enums or rings, not sure which, depends I guess.  What I would like to do is progmatically populate a drop down box and a case structure, so that the case structure executes based upon what is selected in the drop box.  Currently I have been able to populate a ring by importing a CSV file and then porting the resulting array into the rings strings[] property node, and I have been able to populate a case structure automatically from an enum, by wiring it to the case structure and selecting the auto populate opion on the structure, but I have not been able to do both, which is what I need.  Any ideas?  Also I am doing this on labview 2014. 

 

Thanks!

0 Kudos
Message 1 of 8
(4,583 Views)

To be clear... you are trying to programmatically populate a case structure?

 

If so, you can't. Maybe try to explain what you are trying to accomplish and we can provide you with some ideas of how to do it.

0 Kudos
Message 2 of 8
(4,572 Views)

Hi,

 

Thanks for the reply.  I am trying to have a menu that users can use to select a device.  Upon selection I would then like the coresponding cal file, a 2 column csv file, to populate into an array.  I hope that is more clear.

 

Thanks!

0 Kudos
Message 3 of 8
(4,560 Views)

Is this at runtime (i.e. while the VI is running)? If so, you can't - an enum/case structure has to have fixed contents at runtime. If it's at edit-time, then you can use VI scripting to manipulate structures/populate the enum.

 

If you're trying to populate a drop-down box, then using a ring//combo box and set the strings[] property is the way to go but I don't understand then what you mean by populating the case structure. You can have a 'default' case in the case structure to handle unknown/undefined selections from the ring.

 

.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 4 of 8
(4,549 Views)

It will be run time.  It sounds like a case structure is not the way to go. I was trying to use the case structure to read the value selected by the drop box and then use a corresponding case to that selection.  So if I select  value "x" in the drop box then the case structure would then execute a case for value "x".  But the values in the drop box will not be static.  I want to avoid having to change the code every time I add or remove a value from the drop box.  Hope thats more clear.

0 Kudos
Message 5 of 8
(4,533 Views)

Knowing I can't use cases freed me up a bit and I think I have a solution.  I'll use an event to execute when there is a value change in the drop box.  Inside the event a loop will take the drop box value and search for a match in array I used to popluate the drop box, then output the corresponding data.  Hope it works, if theres a reason this is stupid feel free to let me know.   

0 Kudos
Message 6 of 8
(4,523 Views)

Ok, from your description I think you can do something like the following:

 

Have a CSV file containing the device name and calibration file path. On launch, read the CSV file into a 2D array and use that to either:

1) Populate the name/values of a combo box

2) Populate the strings of a ring control

 

You can then use a value change event to get either the file name from the 'value' of the combo box or get the row 'index' from the 2D array and look up the file path that way.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 7 of 8
(4,518 Views)

@UMLEngineer wrote:

Knowing I can't use cases freed me up a bit and I think I have a solution.  I'll use an event to execute when there is a value change in the drop box.  Inside the event a loop will take the drop box value and search for a match in array I used to popluate the drop box, then output the corresponding data.  Hope it works, if theres a reason this is stupid feel free to let me know.   


Feel free to post the code once you have it done and have someone see if they can find a better way to do it... or verify that is the best way.

0 Kudos
Message 8 of 8
(4,495 Views)