LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SCAN FROM STRING

I have a problem with scan from string.vi, I need that a string like "+3.98200000E-06" are converted to a number. What is the correct string format? I tried with %e, %f,... and this vi only convert de first digit. Thanks a lot for your help. I use Labview 5.0.1.
0 Kudos
Message 1 of 12
(3,777 Views)
Hi IMMA,

As far as I know, %f should do the trick. However, you need to take into account the setting for the local decimal point. If your machine is set to use comma "," as decimal point, the scan from string will stop at 3 because it doesn't interpret the dot "." as part of a number. There is an option in LabVIEW to use the local decimal point or not (At least in LV 6.1, I can't remember if it's in LV 5). This might help.

Otherwise (as long as it doesn't upset any other programs) you might need to change the setting for the decimal point on the computer.

Hope this helps

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Message 2 of 12
(3,777 Views)
Hi,

The format into string and scan from string functions can be told to use ","
or "." (in "Edit Scan String" use "Specify Decimal Point character")

Combined with the %f you'll get:

%.;%f

Where %.; specifies to use ".", regardless of the (computer or LabVIEW)
settings.

Regards,

Wiebe.


"shoneill" wrote in message
news:506500000005000000D5620100-1077587809000@exchange.ni.com...
> Hi IMMA,
>
> As far as I know, %f should do the trick. However, you need to take
> into account the setting for the local decimal point. If your machine
> is set to use comma "," as decimal point, the scan from string will
> stop at 3 because it doesn't interpret the dot "." as part of a
> number. There is an option in LabVIEW to use the local decimal poin
t
> or not (At least in LV 6.1, I can't remember if it's in LV 5). This
> might help.
>
> Otherwise (as long as it doesn't upset any other programs) you might
> need to change the setting for the decimal point on the computer.
>
> Hope this helps
>
> Shane.
0 Kudos
Message 3 of 12
(3,777 Views)
Hi Wiebe,

I did not know that. I thought that this was maybe just in LV 7.0, but I just looked in my LV version (6.1) and wow, it's there. I never knew that. Thanks for the info. Shame I can't give your post a rating....

I have encountered this problem quite a lot, and this will help solve many problems in future. I've been programming for 10 years, know LabVIEW really well, but things like this.... really makes the developer Zone priceless.

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 4 of 12
(3,777 Views)
Shane,

Also try the %p option. It is documented in LV7, but works in LV6 as well.

Regards,

Wiebe.


"shoneill" wrote in message
news:506500000005000000DB620100-1077587809000@exchange.ni.com...
> Hi Wiebe,
>
> I did not know that. I thought that this was maybe just in LV 7.0,
> but I just looked in my LV version (6.1) and wow, it's there. I never
> knew that. Thanks for the info. Shame I can't give your post a
> rating....
>
> I have encountered this problem quite a lot, and this will help solve
> many problems in future. I've been programming for 10 years, know
> LabVIEW really well, but things like this.... really makes the
> developer Zone priceless.
>
> Shane.
0 Kudos
Message 5 of 12
(3,777 Views)
OK, I had a look at the help for LV 6.1, but saw nothing about %p. You also haven't explicitly mentioned how this works in your original message.

Can you give me an example of this (textual will do) so that I can try it out? What does the %p option do?

Thanks

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 6 of 12
(3,777 Views)
Shane,

If you use Format Into String with %p it will become clear.

The %p option outputs a number as string, but with "m","M","u" etc. behind
it to indicate milli, mega, micro (pico giga etc.). It's not usefull most of
the time, but may come in handy.

Regards,

Wiebe.




"shoneill" wrote in message
news:506500000005000000EE620100-1077587809000@exchange.ni.com...
> OK, I had a look at the help for LV 6.1, but saw nothing about %p.
> You also haven't explicitly mentioned how this works in your original
> message.
>
> Can you give me an example of this (textual will do) so that I can try
> it out? What does the %p option do?
>
> Thanks
>
> Shane.
0 Kudos
Message 7 of 12
(3,777 Views)
Aha. That's interesting to know. I don't suppose it works scanning from a String?

Thanks again

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 8 of 12
(3,777 Views)
It does.

"shoneill" wrote in message
news:50650000000500000015630100-1077587809000@exchange.ni.com...
> Aha. That's interesting to know. I don't suppose it works scanning
> from a String?
>
> Thanks again
>
> Shane.



[Attachment Format Into String.vi, see below]
0 Kudos
Message 9 of 12
(3,777 Views)
While running the risk of repeating myself, wow. I can actually think of instances where this would be quite useful for me.

Beats manually searching for the "m", "M" or "u" units.

It's just a shame it doesn't work if the input string is 4.3uW for example instead of 4.3u Still, clipping the last character from the string isn't so much work.....

Thanks again.

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 10 of 12
(3,777 Views)