The Scan From File and Scan From String functions do not return a unique error code when an end of file is reached while scanning in a while loop. Two methods for programmatically stopping a scan are shown here: Method 1
- Use the Read From File function to read the entire file. The file is output as a string.
- In a while loop, use the Scan from String function to parse the string.
- Check whether or not the remaining string being scanned is empty. If the remaining string is empty, do not continue the scan.
- Use shift registers to pass the remaining string for the next iteration.
- Use Get File Size to discover the number of bytes in a file.
- Use Scan from File to scan each word out of the file.
- Find the size of the word by using the String Length VI, add this to the number of bytes read.
- Test to see if the number of bytes read is equal to the size of the file. Stop scanning once the total number of bytes has been read.