LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

End of file error

Solved!
Go to solution

Hi all,

 

I have got the following message when reading a file:"end of file encountered" see attached picture.

In fact I want to read the total line amount of my file in order to build an array of element based on this input.

The only way I found is to read the file in a while loop and to stop when EOF is reached, but then I got the erro 4 as described above.

And my program crashed immediately afterwards.

 

Any idea how to solve this issue?

 

thanks for input.

0 Kudos
Message 1 of 3
(3,188 Views)
Solution
Accepted by topic author BENIO

Hi BENIO,

                 You are trying to read a file.Ok

Before the read loop, use the EOF function to return the value of the end of file location.On each loop iteration,compare the Offset output from Read File, or Mark After Read output from Read Lines from File to the EOF value from above.If marker is greater than or equal to EOF, exit the loop.You will still get an error if attempting to read past EOF though. Trap the error by checking the code value from the error out cluster. Use a case structure to clear the error out if the error code is equal to 'Error 4' as you have mentioned.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Thanks as kudos only:)
Message 2 of 3
(3,182 Views)

Why complicate it? Read the Read Text File help, wire -1 to count, r-click function and check Read Lines and you'll get an array of strings out, one for each line. Array length will ofc give the number of lines and you can use the data directly.

/Y 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 3
(3,162 Views)