From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

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,524 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,522 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,519 Views)
Solution
Accepted by 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,516 Views)