11-27-2006 11:28 PM
11-28-2006 12:27 AM
11-28-2006 11:36 AM
11-28-2006 09:55 PM
11-29-2006 12:12 AM
Hi Ryan
I don't know if this is exactly what you are looking for, but the attached vi uses errorcode 4 to terminate the reading of the file. If you use this method, don't forget to check "Read Lines" (right click read from text file.vi, see picture).
Hope this helps.
11-29-2006 11:18 AM
In text based languages like VB, or VC++, there is a boolean called EOF that signifies if the file pointer has reached end of file. This can be used to end a loop. I have just put in a suggestion to NI to include this functionality in all functions that reads from a file. It should work like this. After reading characters from a file, if the file pointer is now at end of file, a boolean EOF output of the Read File vi should become true, otherwise it should be false. The EOF output can be used to stop a loop. Very useful.
Here is a scenario: I read 1 character at a time from a file in a loop. In some iteration the file pointer is at the last character. At that time, EOF output from Read File is false, no errors. Then in the next loop iteration, I call Read File to read 1 character. EOF becomes true and the loop stops, no errors. If I would have requested to read more than one character, the file pointer would be past the end of file (theoretically), and EOF would be true and also an error would be generated signifying that I tried to go past EOF. Hopefully, NI will incorporate this functionality in the next LV version.
11-29-2006 11:34 AM
11-29-2006 11:52 AM
This is my workaround to avoid any errors:
Before the read loop, I use the EOF function to return the value of the end of file location.
On each loop iteration, I 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 can 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.
11-30-2006 12:01 AM
Hmm....
That sounds as if you were describing my vi. I wonder if my attachments were looked at.... 😉
06-06-2013 02:25 AM - edited 06-06-2013 02:27 AM
Hi,
following your sample, I made the following vi. I want each line to be entered as elements in the array. but somehow that s not happening.. not able to figure out where i m going wrong. can you help?
using NI LV 8.6
thanks.