10-17-2008 09:24 AM
Hi
I'm new to Labview (ver 8.6) and I'm running into this problem.
I'm using Scan From File to get a number of setup information from test.txt. The data in the file looks like this:
AAA 1
BBB 2
CCC 3
I've noticed that the Scan From File works for only the first line. Attempting to get data that is not in the first line results in an Error 85.
Any Ideas? Thanks
Solved! Go to Solution.
10-17-2008 09:31 AM
"e:\scanfile.png" is sadly no webpublished filepath.
Please post the image first and then insert it into you post.
thanks,
Norbert
10-17-2008 09:44 AM
10-17-2008 10:03 AM
The error is expected.
Please note the help to the function you use:
Use this function when you know the exact format of the input.
In your example, the first time the input starts with AAA, so "AAA %s" as formatstring fits the first part of your input.
But you remove AAA 1 from the string, leaving a new line command before BBB.
So your string looks like:
"
BBB 2"
Therefore, it does not start with BBB and the second function will create the error.
If you can't remove the new line command, you can either load the whole file and parse it using "Scan from String" and configuring a correct offset for each call, or you have to work with other functions like "Match Pattern".
hope this helps,
Norbert
10-17-2008 10:14 AM
It's all in what the scan from file reads, and what the next cgaracter in the file is.
Your first scan from file will read up to but NOT including the first newline in the file.
The second read reads from where the first read left off, and expects to see "B" as the next character, but instead sees the new line, and so the scan fails. You need to tell the second formatted read to expect the newline.
You can do this by making the FIRST character of the format string a space, which will tell it to expect any number of "white space" charaters.
Yo can in fact put a space at the beginning of the format string in your first scan from file and it will match with zero white space characters before seeing the AAA. By doing this it is also tolerant of seeing spaces and tabs before your AAA or BBB identifiers.
Rod.