From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, 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 Variable Order (%$) is not working

Solved!
Go to solution
Solution
Accepted by ArturoCarranzaFMC

Arturo,

 

I can confirm that the "variable order" format syntax does not work for Scan From String in my LV2019 installation, so it's likely it was never implemented in Scan From String, but only Format Into String.  I agree with the others, it's a pretty specialized feature that could be confusing to an eventual code reviewer/maintainer, unless there's clear commentary about why it was used.

 

If you need more flexibility in parsing textual input into string tokens, perhaps the Match Regular Expression primitive (shh, it's actually an XNode) could be a useful alternative.  If you haven't used regexes before, the syntax can be a little daunting, but there are some cool online tools.  The ability node of the LabVIEW Match Regular Expression XNode actually allows you to return submatches as an array - I can vaguely envision where you could build a tool that parses well-formed XML into tokens, that then can variably-index the resultant match set.  But perhaps I'm overreaching.

 

Best of success!

Dave

David Boyd
Sr. Test Engineer
Abbott Labs
(lapsed) Certified LabVIEW Developer
Message 11 of 13
(380 Views)

Thanks @DavidBoyd, I'll explore that option.

 

Thank you

0 Kudos
Message 12 of 13
(368 Views)

@ArturoCarranzaFMC wrote:

Hi @Bob_Schor, I'm not sure I understand, so my code with Scan from String should work? If it could work it would be easier to edit the format specifier from an external source so I wouldn't need any change to my code and I could have it easy on the verification and validation. Swapping wires it's a change in the code so I would need to update requirements and test procedures, elaborate a test report, organize a design review and document it just to swap the wires, it would take from weeks to months, so it's much easier if I could swap data just by updating an external source without any code modification.


You miss my point.  However you break the string "Smith John" into the string "John" and "Smith", it involves switching the order.  You can "hide" this maneuver inside the Format string, or you could explicitly cross the output wires making it obvious to the person (maybe even yourself) who looks at the code 6 months later and wonders "why are the two parts getting interchanged?  I put in "Bob Schor", and I expect to get "Bob" and "Schor", but somehow "Bob" becomes "Schor" and "Schor" becomes "Bob" ..."

 

Of course, you put a big 24-point Comment on the Block Diagram that says "This function reverses a two-word string", right?

 

Good LabVIEW code is Obvious LabVIEW code, no hidden tricks.

 

Bob Schor

Message 13 of 13
(351 Views)