09-25-2019 01:11 PM
So I have a spreadsheet string that has the following line somewhere. The value changes so I want to extract it.
IndexedValues=1.000000E-3;
So I use scan from string with the following as the format string "IndexedValues= %e"
I have tried the following, all which give error 85 (string doesnt match), so I am extremely confused. This is just one number to be extracted.
"IndexedValues= %e"
"IndexedValues= %e;"
"IndexedValues= %f"
"IndexedValues= %f;"
09-25-2019 01:19 PM
%f should be sufficient. Can you attach a simple VI that contains a few typical string as diagram constant. Could it be there are hidden characters (nonprintable, tabs, etc.).
(You could just search (using match pattern) for "=" and scan the "after substring".)
09-25-2019 01:27 PM
Thanks for the idea of searching. If I match IndexedValues=, it works perfectly. I guess the file probably has something hidden.
09-25-2019 01:37 PM
If the hidden characters are always the same, just get one input string, create a constant from it, replace the number string with %f, and use it as format, leaving all the rest as is.
(Also use \-codes display to see what's actually there.)
If the string is well formed, all your formats should just work:
09-25-2019 01:55 PM
In your example above the expected string is "Value=1.0" while your input to the ScanString is "Value= %f". If you noticed, you included a space character in your scan string.
09-25-2019 02:34 PM
@Mark_Yedinak wrote:
In your example above the expected string is "Value=1.0" while your input to the ScanString is "Value= %f". If you noticed, you included a space character in your scan string.
That space does not matter:
09-26-2019 05:39 AM
What about using "%.;IndexedValues=%f" as format string if you know that the input string always will use a decimal point rather than a system depending decimal character?
What most likely happens is that your system has a decimal comma as local decimal character configured. The Scan from string looks for that, doesn't find it and stops at the decimal point since it can't be part of a floating point number, returning 1,0 as value. Then your format string contains a literal semicolon which doesn't match with the decimal point in the string at the current scan position and hence error 85.
09-26-2019 08:57 AM
@jmaslek a écrit :
So I have a spreadsheet string that has the following line somewhere. The value changes so I want to extract it.
IndexedValues=1.000000E-3;
Scan From String needs to know the exact format of the input, if you have other text before what you're looking for you will get error 85. Use Match Pattern.vi instead.
Ben64
09-26-2019 11:08 AM
@rolfk wrote:
What most likely happens is that your system has a decimal comma as local decimal character configured..
Since starting scanning after finding the "=" solved the problem, localization was not the issue, but sill something to keep in mind.