From Friday, January 17th 11 PM CDT (January 18th 5 AM UTC) through Saturday, January 18th 11:30 AM CDT (January 18th 5:30 PM UTC), ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

ScanFile with scanning string modifier %s[in]

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?    

0 Kudos
Message 1 of 5
(4,069 Views)

Hi,

 

I cannot help you with the early versions of CVI, I have uninstalled them a long time ago Smiley Happy

 

But for CVI2013, I have tried your example and it works as described in the documentation...

 

Scanning String Modifiers

 

ModifierMeaningDescription
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.

Message 2 of 5
(4,054 Views)

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.

0 Kudos
Message 3 of 5
(4,047 Views)

OK, caught me, I have to admit that I only tried Scan with CVI2013, not ScanFile...

0 Kudos
Message 4 of 5
(4,043 Views)

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.

National Instruments
0 Kudos
Message 5 of 5
(4,004 Views)