LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Scan function String (Comma Delimited) to Real Float Array

Hi All,

 

I am reading a string from a Oscope through TestStand 2010 that has 600 data points where the string looks like this:

"-1.040000E+00, -1.040000E+00, -1.040000E+00,....  -1.040000E+00, -1.040000E+00, -1.040000E+00, -1.040000E+00, -1.040000E+00, -1.040000E+00, -1.040000E+00, -1.040000E+00, -1.040000E+00, -1.040000E+00, -1.040000E+00, -1.040000E+00"

 

I used the scan function but it returns:

array[0] = 1.398048557154e-076

array[1] = 2.400441566266e-310

array[2] = 0

until (all zeros)

array[599] = 0

 

My format string is "%s>%600f[x]"

What am I doing wrong?

Capture.PNG

0 Kudos
Message 1 of 4
(4,457 Views)

 

As 2.400441566266e-310, when held in memory as a double is "-E+00,  " in ASCII, I suggest you check your pointers. 

 

If you convert a single value, does it behave as expected?

 

Do you mean double, rather than "real float"?

0 Kudos
Message 2 of 4
(4,431 Views)

As far as I can understand, those strange values in the output array are simply the result of uninitialized variables: you could try initializing the array with Set1D (array, 600, 0.0); before scanning the string.

On the other hand, the scanning command appears to be correct. You can address this situation by verifying the return code from Scan () function: if it returns -1 then you can call GetFmtIOErrorString to get a meaningful string describing the error; if it returns -1 you can use GetFmtErrNdx to find the position in the format string where an error has been found.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 3 of 4
(4,404 Views)

Thanks for your solutions!  I will try them out.

0 Kudos
Message 4 of 4
(4,391 Views)