From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read from a created text file

Solved!
Go to solution

I have hopefully a quick question.

 

Why doesn't the read from text file work in this example?

 

Thanks

 

 

Example_VI_BD.png

 

Dan Shangraw, P.E.


   

0 Kudos
Message 1 of 5
(2,959 Views)
Solution
Accepted by topic author ASTDan

When you write to a text file, LabVIEW keeps a pointer along with the reference while you have the file open. So after you write "test" to the file, your new pointer is now at location 4. When you Read after that, it reads from pointer 4 and on.

 

Use the Set File Position function in the advanced palette to read from position 0.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 5
(2,952 Views)

I think you need to set your file position back to zero after the write. You're reading back from the position after your write which is probably empty.

EDIT: James is too fast for me 🙂

Message 3 of 5
(2,950 Views)

Sorry, Taki!

 

ASTDan, this altered version of your code will just result in a file getting larger and larger with each run with "testtesttesttest" and so on.

 CreateWriteReadClose.png

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 4 of 5
(2,942 Views)

Thank you!

 

Was really scratching my head on that one.

Dan Shangraw, P.E.


   

0 Kudos
Message 5 of 5
(2,927 Views)