Error 4 After Multiple Calls to Read From Measurement File Express VI

Updated Sep 14, 2023

Reported In

Software

  • LabVIEW Base
  • LabVIEW Full
  • LabVIEW Professional

Issue Details

I am using the Write and Read From Measurement File VIs multiple times in my application. The first time I read from the file it works fine but after some time the Read From Measurement File VI gives the following error.

Error 4 occurred at Read From Measurement File -> MyVI.vi.

Possible reason(s):
LabVIEW: End of file encountered.


How do I prevent this?

Solution

Error 4 indicates that file position pointer has reached the end of file (EOF) and it is not being reset to read the beginning of the file again. To fix this, create a shift register and wire the boolean EOF? value from the Read From Measurement File Express VI to the Reset field of the same Express VI. A visual example of this can be seen below. This will force the Read From Measurement File Express VI to read from the beginning of the file again and should prevent the Error 4 message.

Additional Information

This file position used with the Read From Measurement File Express VI will also be reset to the beginning of the file every time LabVIEW runs the VI, however if you would like to read from the same file again after reaching EOF in the same application instance you will need to implement something similar to the example shown above.