08-14-2013 12:04 PM
For skipping over non-numeric characters by reading ASCII files I used to write, e.g.
ScanFile (fhandle, "%s[i8]>%f", &x);
This method works well with CVI 5.0 to 8.11 but no more with CVI 2009 and 2010. I have modified my old code using other scanning string modifiers:
ScanFile (fhandle, "%s>%s[dt#]%f", &x); or
ScanFile (fhandle, "%s>R1= %f", &x);
The first one does not work with a string like “R1=200”. The second requires the exact string and is more inconvenient. Although the modified code works well now with CVI 2009, I would like to know why the scanning string modifier [in] does not work with CVI 2009 and 2010. Is there something wrong in my code, is it a feature of the new versions of CVI or is it a bug? How about CVI 2013?
08-15-2013 09:42 AM
Hi,
I cannot help you with the early versions of CVI, I have uninstalled them a long time ago
But for CVI2013, I have tried your example and it works as described in the documentation...
Modifier | Meaning | Description |
---|---|---|
in | Specify array offset | The i string modifier specifies an offset within a string. This modifier indicates the location within the string where processing begins. n is the zero-based index of the first byte to process. |
If you use the in string modifier processing of your string will start only at character n.
In your case of "%s[i8]>%f", &x this means that the string "R1=200" results in x=0, whereas "%s[i1]>%f", &x gives you x=1.
08-15-2013 12:18 PM
Thank you very much for your reply.
I would not use "%s[i8]>%f" to read the number 200 in string "R1=200". I just wanted to take this string as an example to say that I couldn't simply change all of "%s[in]>%f"s in my code to “%s>%s[dt#]%f"s, somewhere I had to use a quite inconvenient "%s>R1= %f". Therefore I do hope that "%s[in]>%f" works by a new version of CVI.
In my code I use a lot of Scan (string, "%s[in]>%f", &x) and all of them work always correctly, also with CVI 2009-2010. But none of ScanFile (fhandle, "%s[in]>%f", &x) works with my CVI 2009, they work only with earlier versions.. That’s very strange to me as I couldn't find in the documentation/Help of CVI 2009-2010 a description that "%s[in]>%f" should not be used with the ScanFile function,
My further tests showed that this problem seems to be related to CVI Run-time. By reading the same ASCII file, the same executable created by CVI 8.11 works with CVI Run-time 8.1 but does not with Run-time versions 9.0 to 10.0.1.419.
08-15-2013 12:56 PM
OK, caught me, I have to admit that I only tried Scan with CVI2013, not ScanFile...
08-20-2013 03:15 PM
I can confirm that this format specifier does not work in CVI 2009 and later (including CVI 2013) for the ScanFile function. I filed a bug report to investigate this. You can track this issue with bug ID 422953. I'll keep you up to date on any progress we make on debugging this issue.