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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Scan from String loses auto-determined type when separated from format by Case

I am using LabVIEW 8.0.1 on Windows XP. I observe that the String -> Scan from String function has outputs that correspond to the "format string" input. For example, if you wire a constant "%T" or "%d" to the format string, then you will get a date stamp or int32 output. This seems to work even if the constant format string wire crosses a for-loop, while-loop, or sequence boundary. However, if the format string wire crosses a case structure boundary, this fails. For example, if the constant format string is outside the case structure and the Scan from String function is inside the case structure, the function output reverts to type double, and I cannot get a wire of the correct type unless I make a typed wire to the default value input.
 
This is annoying, especially when I want to use the same constant format string in different parts of the block diagram.
 
To replicate this error: put a "Scan from String" function onto a blank block diagram and wire a format string of "%T" to the input. Create an indicator at the output. Everything works fine.  Then, draw a case structure around the function, keeping the format string out of the case structure. Note how the block diagram is now broken (even after wiring a TRUE constant to the case structure input).
Message 1 of 4
(2,768 Views)
I agree this looks like a small bug.
 
The automatic format typing does not survive the boundary of a case structure or event structure. 😞
0 Kudos
Message 2 of 4
(2,767 Views)

I don't think this is a bug.  The string functions that take a format specifier (Scan from String and Format Into String being the two most common) will automatically type the inputs/outputs if you wire a string constant.  For anything else, you must define the type yourself.  This is because LabVIEW doesn't try to traverse the path of the format specifier to its source.  And even if it tried, it wouldn't be perfect.  For instance, what if you used a Select function to choose between a string constant and a string control to wire into the format specifier input?  Even though one of the possible sources is a string constant, the other one isn't, so LabVIEW has no way of knowing how to type the inputs/outputs.  In the case mentioned in this thread, the user should just wire a Timestamp constant to the first "default value" input to explicitly define the type of the first output.

Would it be more helpful if the documentation for these functions indicated that LabVIEW will only assign type to inputs/outputs if a string constant is wired *directly* to the type specifier input?

-D

0 Kudos
Message 3 of 4
(2,759 Views)
OK, it just seems a bit inconsistent if it survives the boundary of a FOR, WHILE, TIMED, SEQUENCE etc., but does not survive a CASE or EVENT boundary.
 
(It is clear that there could be a logical problem on a case/event output tunnel, but not on an input tunnel as in this case.)
 
Two things:
  1. It should always work if the format is a diagram constant. Can't LabVIEW just "fold" the constant across these boundaries?
  2. Whenever the format is determined at runtime (control, code, etc.) the default type needs to be wired. This should maybe be better documented.

Wow, it's late Friday night! 😄

Message 4 of 4
(2,756 Views)