04-13-2023 03:14 PM
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
04-13-2023 05:06 PM
Thanks @DavidBoyd, I'll explore that option.
Thank you
04-13-2023 07:35 PM
@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