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.
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.
03-17-2011 10:52 AM - edited 03-17-2011 10:53 AM
I was a bit surprised when I found out that the Scan Value function will not scan the SI unit prefix when there is characters following the SI prefix. For example in the following snippet I expected the output to be a double value of 0.205 and remaining output string to be "A" but is stops before the "m" in its scan and provides 205 with "mA" remaining. It does scan the "m" if there isn't anything after it in the imput string. Is there something else I should add to the format string? Would this be considered a bug?
03-17-2011 04:19 PM - edited 03-17-2011 04:21 PM
if you try to type '205mA' into a numeric control or indicator, it will revert to the default value.
You will need to remove the units and leave only the value and SI magnitude.
SI standard formatting normally places a space between the value and units (magnitude is prefix to units).
This example should work for other locales where the , is used as the decimal separator
03-17-2011 04:59 PM - edited 03-17-2011 05:00 PM
@Phillip Brooks wrote:
if you try to type '205mA' into a numeric control or indicator, it will revert to the default value.
You will need to remove the units and leave only the value and SI magnitude.
SI standard formatting normally places a space between the value and units (magnitude is prefix to units).
This example should work for other locales where the , is used as the decimal separator
Why is that true for the %p format and not for the %e? I would expect this example to produce the same value after the scan but they don't. Why does the %p scan stop if there is anything after the magnitude?
03-18-2011 01:33 PM
Hi Paul, this is also Paul, with National Instruments.
http://zone.ni.com/reference/en-XX/help/371361G-01/lvconcepts/format_specifier_syntax/
http://zone.ni.com/reference/en-XX/help/371361G-01/lvhowto/characters_numeric_control/
It looks like your problem is that your A for Amps is not recognized as an accepted character per the second link.
As you stated, with A removed the function works correctly. Are you always expecting a unit on the end of the string? If so could you not just remove the last character?
Per the way our functions are set up to handle this syntax, I do not see this as a bug. It may be worthy to submit to our idea exchange if you would like this implemented as a future feature: http://ni.com/ideas
03-18-2011 02:17 PM - edited 03-18-2011 02:17 PM
03-21-2011 04:50 PM
Paul,
I am currently in the process of looking into this further. It seems like it may be unexpected behavior, but I will dig a little deeper and see what I can find.
Thanks for your feedback!
Drew T.
03-21-2011 06:08 PM
Thank you, and all please excuse my bad attitude in my previous post. Just a little frustration venting.
03-23-2011 07:02 PM
Paul,
I have spoken with several LabVIEW experts on this issue, and have determined that this is not unexpected behavior. When the Scan Value function looks at the string, it takes all of the characters after the number and compares them to its know list of SI prefixes. It does not search character by character.
However, I can see where this might be useful and would encourage you to post it on the Idea Exchange as Paul D. suggested earlier.
You could look into the Format into String function to account for units. See the {Unit} tag in the following link for more info.
http://zone.ni.com/reference/en-XX/help/371361G-01/lvconcepts/format_specifier_syntax/
Best
Drew T.
03-23-2011 08:30 PM
I have spoken with several LabVIEW experts on this issue, and have determined that this is not unexpected behavior.
Well I didn't expect it. I actually could not find an good example of %p in the help examples but did find examples for %e and %f as in here and here. So, can you answer this; if I can expect (for scaning %e):
string | offset | default | offset past number | number | Comments |
---|---|---|---|---|---|
–4.7e–3x | 0 | 0 | 7 | –0.0047 | x is not allowed, so conversion stops there. |
why can I not expect 200mX to equal 0.200 when scanning %p?
... When the Scan Value function looks at the string, it takes all of the characters after the number and compares them to its know list of SI prefixes.
Yes that seems to describe the behavior but in my opinion that implementation was very short sighted and also doesn't seem to fit with the other format specifiers (like %f and %e).
You could look into the Format into String function to account for units. See the {Unit} tag in the following link for more info.
http://zone.ni.com/reference/en-XX/help/371361G-01/lvconcepts/format_specifier_syntax/
{Unit} (optional) | Overrides the original unit of a VI when you use a function to convert a physical quantity (a value with an associated unit). You must use a compatible unit. You can use this syntax element only with the Format Into String function. |
Thought for a second that this might work for me but read the fine detail... I need to scan from string not format to string.
03-23-2011 08:38 PM - edited 03-23-2011 08:39 PM
One more example of "expected behavior"...
Personally I would expect the follow three outputs to produce the same value when executed. Wouldn't you?