LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading text file

Solved!
Go to solution

I am trying to read the text file. The text file is having multiple lines of text. I am using Read from text file function available in the file I /O.  

 

Please find attached the 2 snapshot of the block diagram. Image 1st (i.e txt1) is working perfectly i.e. it is reading all the lines available in the text file. But VI shown in the second image (i.e txt2) is showing only first line of the text file. I am using the same function in the both VI i.e. read from text file

 

Question :-

 

1)      what is difference between the two “Read from text file” function

2)      how to make the second VI working same as the first one?

Download All
0 Kudos
Message 1 of 7
(3,710 Views)
use the read from spreadsheet function and here is an example of that:
Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 2 of 7
(3,707 Views)

Can't debug a picture.

 

Do you have lines or characters selected. Are you reading the same file with both functions?

 

Attaching the two VIs and the text file(s) would help you get the question answered.

0 Kudos
Message 3 of 7
(3,689 Views)

Hi All ,

 

I have attached both VIs & the text file I am trying to read. Readtxt1.vi will read only the first line of the text file where as the readtxt2.vi will read the full text file.

 

In both the case I am using read from text file function but result are different . My queries are

 

 

1)      what is difference between the two “Read from text file” function

2)      how to make the second VI working same as the first one?

 

 

Thanks in advance

LabV

 

 

Download All
0 Kudos
Message 4 of 7
(3,661 Views)
Solution
Accepted by topic author Lab V

Right click on the VI and you will see an option in the right click menu for Read Lines.  I suggest hitting Ctrl-H and turn on context help to look at this function.  Go into detailed help for more details.

 

If you're reading lines, then you get an array of strings.

 

By the way, it makes no sense to have a while loop around your Read functions.  And even less sense to have the Cancelled output wired to the stop terminal of the while loop.

 

 

 

Changing the Read Lines and checkmark and wiring the "count" input shows there might be a bug with the way this Read Text File VI is configured.

 

1.  With count unwired,  either Read Lines or Not is wired just fine to the string indicator.

2.  With Read Lines not checked, create a constant for count.  It is wired just fine to the string indicator.

3.  With Read Lines checked, create a constant for count.  The output wire breaks because it is an array of strings going to the string indicator.

4.  Uncheck Read Lines.  Constant is still wired.  The output wire remains broken.  Why?

5.  Leave Read Lines unchecked.  Delete the constant.  The output wire fixes itself.

6.  Leave Read Lines unchecked.  Recreate the constant.  The output wire remains just fine.  Although the setup is now the same as #4, it is all wired like it should be.

7.  Go in and check Read Lines.  The constant is still wired.  The output wire remains just fine.  Why?  Although the setup is the same as #3, the wire is okay even though it shouldn't be.

 

It is like the compiler only checks the wire data types if you create constants.  Not when you change the Read Lines setting on the VI.  Only if you try to run the VI in #7 will the VI break, give you and error, and show you the broken wire.  I would consider this a bug.  (Interestingly, I had to do a screen capture to get this screenshot.  Using the code capture tool forced a compiler check that made the lower two wires fixed or broken as they should be.

 

 

Message Edited by Ravens Fan on 07-01-2009 02:37 AM
Message 5 of 7
(3,653 Views)

Thanks A lot All especially Ravens Fan

 

 

0 Kudos
Message 6 of 7
(3,603 Views)

Ravens Fan wrote:
......

I would consider this a bug.  (Interestingly, I had to do a screen capture to get this screenshot.  Using the code capture tool forced a compiler check that made the lower two wires fixed or broken as they should be.

 

Cool you can use the Code Capture Tool to debug fix your code!

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 7 of 7
(3,578 Views)