Showing results for 
Search instead for 
Did you mean: 

Choose Different Paths



I have done a program. Here I just use 2 string control and give it to write to a spreadsheet file, to save what is typed in string control to the file. Now the file path to be given to write to spreadsheet file, I have to choose between two. My main motive of the program is choosing between the two. For that I used 2 buttons, enum and case structure and while loop. My doubt is can this be done in a better way than this. I need to use this in another program. Also there it is not choosing between two, but there are atleast 5. So I will have to use 5 buttons there. So can I do this in a more simple and better manner. I have uploaded the code. Thanking You in advance.

0 Kudos
Message 1 of 4

I don't doubt that it can be done better.  Perhaps you have a question?


Try looking at radio buttons for choosing among different files.  Instead of multiple select functions, the value from a radio button control can be wired to the index of an Index Array function.  That array would be an array of file paths and it would index out whichever path you used at the moement.

0 Kudos
Message 2 of 4

There is no need to create two states for this. If you have only two choices, a single boolean is sufficient. (you only need two booleans if you have four possible options (no file, file 1, file 2, both files).


I would place all possible file names into a listbox and e.g. use a double-click event to act on it. Now things are scalable and the code can be used for any number of selections without any further change in code.


Learn how to use event structures. Currently your code hammers the CPU, spinning as fast as possible while repeating mostly the same operations over and over for no good reason at all. I would also not chop up the code so much. you could do the file IO in a state handling 1&2 directly.

LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 3 of 4



I agree that there are some things that are possible to tweak:

  1. use a event structure instead of polling for the reaction to the user input
  2. perhaps use an enum/text ring instead of an button so the number of files is extendable and it is self documenting
  3. use typedefs for the state machine enums so you can extend/correct your program more easily

Best regards,


Staff Applications Engineer
National Instruments
Certified LabVIEW Developer (CLD), Certified LabVIEW Embedded Systems Developer (CLED)

Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved
0 Kudos
Message 4 of 4