07-23-2012 03:43 AM
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.
Solved! Go to Solution.
07-23-2012 03:55 AM
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.
07-23-2012 06:10 AM
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