LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

parse string to floating points

Hi,
 
I'm trying unsucessfully to parse the following string out to multiple outputs of floating point.  Any idea?
 
Input String:  
              Data      1            5           8          11
                      15.134   12.682    3.583    0.534
Want output to look like
 
output1: 15.134
output2: 12.682
output3: 3.583
output4: 0.534
 
thanks,
Anh
 
0 Kudos
Message 1 of 6
(3,233 Views)

How about searching numbers in the right format using Match Pattern like this.

You didn't say what LV version you are using

David

Message Edited by David Crawford on 05-10-2006 01:03 PM

0 Kudos
Message 2 of 6
(3,224 Views)

Thanks David, I did the variant of your recommendation, but using the "scan from string" function after stripped off the Data tittle.  However, if the input string is not exactly what the format string look for (ex: %8.3f..), the error "LABVIEW: An input parameter is invalid" will occur.  How do I get around this error?  For example if my input string is empty or junk (uncontrolled output from other vi), I want to set data 1-11 to a default value.

thanks,

Anh

 

0 Kudos
Message 3 of 6
(3,203 Views)
Anh
 
If thats what you want then you can get around it. Just wire the error out from the scan from string to a case statement selector. It will automatically fill out the error and no error. Pass through the scan from string values through both cases. Like this
 
 
David

Message Edited by David Crawford on 05-12-2006 10:28 AM

0 Kudos
Message 4 of 6
(3,196 Views)
I kind of find a way to handle the error by using the case structure selection if the input string doesn't contain "Data" as in example below.  But I don't think the solution is quite roburst since even the Data is matched, the rest of the string might not match the %8.3f required.  I wonder if there is a way to tell the "scan from string" function to ignore the unmatched data and set its outputs to a default value instead of stop the program with an error code.
 
thanks,
Anh
0 Kudos
Message 5 of 6
(3,193 Views)

David,

my kudos to you! This is exactly what I'm looking for (got your reply after I sent my last question).  I totally forgot that error out has to be handled to avoid program interruptionSmiley Sad

thanks for your help and your promptly response,

Anh

0 Kudos
Message 6 of 6
(3,190 Views)