LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I make a table with a list of names using "Read from Text File Function" block without getting error 43?

Solved!
Go to solution

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?

Download All
0 Kudos
Message 1 of 12
(3,799 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 12
(3,752 Views)

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? 

0 Kudos
Message 3 of 12
(3,744 Views)

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.

Textonthetable.png

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.


GCentral
0 Kudos
Message 4 of 12
(3,737 Views)

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?

0 Kudos
Message 5 of 12
(3,721 Views)

@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:

  • click on the image once to open a not-really-zoomed version (urgh...)
  • furthest right button is download (probabyl have to hover to get the tip-strip to check it's the correct one, I rarely get the icons to appear)
  • open Windows Explorer, navigate to the image (e.g. Downloads, etc)
  • open LabVIEW, have a block diagram visible
  • Drag the .png file from Win Explorer into LabVIEW's block diagram. Keep holding it over the BD until it switches to the appropriate bit then drop. It should place code (not an image).

 

Assuming the above to be true (re selecting a user) here's an example/solution that might help:

text-table.png

  • 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

GCentral
0 Kudos
Message 6 of 12
(3,716 Views)

@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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 12
(3,703 Views)

Knew there was a built-in string type version but didn't find it on the palettes after a quick search. Must remember - "combo box"...


GCentral
0 Kudos
Message 8 of 12
(3,700 Views)

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.

Listbox.PNG

 

Download All
0 Kudos
Message 9 of 12
(3,668 Views)
Solution
Accepted by GRC5000

Then as you found, you can use a Listbox.

 

Example_VI.png

 

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.


GCentral
0 Kudos
Message 10 of 12
(3,658 Views)