10-07-2019 08:44 AM
I have attached my VI and the text file I would like on the table. I cannot run the VI continuously without getting an error. Can someone please help me?
Solved! Go to Solution.
10-07-2019 11:12 AM
Error 43 is "User Canceled". So you are the one who canceled the file dialog box. So first of all, why are you running this VI continuously? Seems like it should only need ran once.
10-07-2019 11:21 AM
Hi crossrulz,
Thank you for your reply. The reason I am running continuously is so that I can be able to select whatever names from the list. I'm not sure if running it once will allow me to select a name. What do you think?
10-07-2019 11:32 AM
The "Run Continuously" button probably shouldn't be used very much (only for specific cases, like testing the change of a VI to an input control, and so on).
What you might instead consider is the use of a Loop (e.g. For or While).
You mention a table, but have instead a String indicator. Do you want to display the text file on the string indicator? Or do you want to populate a table with column headers (the names)?
For the first, use Read from Text File just once, with the current setup. It will prompt for a File (because you didn't connect a Path input to the Read function) but then work fine.
If you instead want a table, you need a 2D array of strings and a table indicator.
Here I used a node that returns the Current VI's Path, then Strip Path (to get the directory) and Build Path (to add the txt file name) to create the path you need for the file, when the VI and txt file are in the same directory.
10-07-2019 12:01 PM
Sorry for being a headache.
I like that you have a screenshot of the vi. The main problem I'm having is how do I select a name from the list on the box on the left if the VI cannot be run continuously? If you can help me with that then my problem will solved. Hence, case will be closed.
Thanks for helping.
P.S.: Can you post your vi link?
10-07-2019 12:05 PM - edited 10-07-2019 12:12 PM
@GRC5000 wrote:
The main problem I'm having is how do I select a name from the list on the box on the left if the VI cannot be run continuously?
Little unclear here. Do you mean you'd like to perhaps populate a dropdown list, then choose only a specific name (as a string) to use later on in the VI? I'm imagining this is part of a login interface or something now?
@GRC5000 wrote:
I like that you have a screenshot of the vi.
...
P.S.: Can you post your vi link?
The image is a "VI Snippet" - it should be possible to drag it into a block diagram and it will populate with the code. The forums are a little finicky with this, you might have best luck doing the following:
Assuming the above to be true (re selecting a user) here's an example/solution that might help:
10-07-2019 12:27 PM
@cbutcher wrote:
- First I get the names as a 1D Array by right clicking the Read function and choosing "Read Lines".
- Then, I pass this array of strings into the "Strings []" property of a Text Ring. This is a numeric control with a set of strings associated.
- I use the error out wire to ensure the strings are populated before the Event Structure can start
- I set the Event Structure to only process the "Select" button value change (i.e. when I click the Select/Login/Whatever button). (See the linked document for more details).
- I index the array of strings with the value of the text ring to get the currently selected name
If you change that Text Ring into a ComboBox, you do not need the Index Array. The value of the ComboBox is the selected string. So just save yourself a step.
10-07-2019 12:34 PM
10-08-2019 09:26 AM
To answer your question "Do you mean you'd like to perhaps populate a dropdown list, then choose only a specific name (as a string) to use later on in the VI?" Yes, sort of.
The image below is what I am trying to do, but in the image I used a listbox just for you to have an idea of what I want. Notice how the VI is running and the name Steve is selected just by clicking once on the name "Steve".This is exactly what I want. But I want to do it using "read from text file" block or similar block that prompts the user to use a file. The VI that you sent is good and I think you understood what I want but if you can just help me select a name by clicking "once" on the name from list without clicking the select button, then you'd solve my problem.
You are on the right track.
Thank you for your help.
I have attached the VI for the image.
10-08-2019 09:34 AM
Then as you found, you can use a Listbox.
Here I set the Value to -1 before the Event Structure starts (to deselect), then check for a Value Change event on the listbox (instead of using a Select button).
The same is possible with the Ring I used previously, but I'm not sure if you wouldn't have had problems if you didn't change (e.g. you wanted to select the top value) so I added the button.