NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I fetch number in string and convert it to double?

Solved!
Go to solution

My string is like: ".... angle: 39.5 bla bla..." and stored in a buffer "Locals.rString".

I want to fetch "39.5" and convert it to double to store in "Locals.acıDegeri"

Thanks.

 

0 Kudos
Message 1 of 4
(3,530 Views)

Put this in your statement step.

locals.str2=Mid(Locals.str,3,4),locals.num=Val(locals.str2)

 

 

 

Locals.str and locals.str2 are string type.

Locals.num is a number type

 

Locals.str has "sss49.2lll"

0 Kudos
Message 2 of 4
(3,528 Views)

Mid(string, startIndex,<numChars>) 

You wrote startIndex=3 but it is not 3, actually I also don't know what it is because my string contains information from rs232 channel.

But converting part is true I think.

 

Do you know a expression which fetches after ":" character?

0 Kudos
Message 3 of 4
(3,525 Views)
Solution
Accepted by topic author aselim

locals.num1=Find(Locals.str,":")

 

Use find function to get the location of :

 

Then use the mid function to extract the value

 

0 Kudos
Message 4 of 4
(3,522 Views)