09-01-2015 09:47 AM
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!
09-01-2015 09:53 AM
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.
09-01-2015 09:57 AM
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!
09-01-2015 10:03 AM
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.
.
09-01-2015 10:15 AM
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.
09-01-2015 10:29 AM
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.
09-01-2015 10:32 AM
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.
09-01-2015 11:54 AM
@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.