String array bug

For general discussion related FlowStone
Post Reply
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

String array bug

Post by tulamide »

While working on string conversions, I stumbled upon this pesky little annoyance. Using the text box or string box to generate a string array, every char is recognized but not the comma! Only by building a string array via the string array prim, the comma is recognized.

Here is a schematic, which should make the issue obvious.
Attachments
String_Bug.fsm
Example of the comma not being recognized by string-to-string-array conversions.
(1.28 KiB) Downloaded 768 times
"There lies the dog buried" (German saying translated literally)
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: String array bug

Post by KG_is_back »

I think the problem is how text to string array conversion is handled. Basically, text primitive outputs a string. To convert it to string array, some delimiter is required. "," comma and "\n\r" newline characters are two separators (note that whitespace after and before the comma/newline is also ignored).

In your example, the first method (text prim connected to string array connector) comma is considered a delimiter of two empty strings. You can observe this behaviour is true, by creating a ruby component with string array input and then "watch" the input - you will see an array of two empty strings.

In the third example (the one that works) "," string is specifically added to the previously empty string array. If you connect the output of that prim to previously mentioned ruby component, you can clearly see this.

conclusion: Via text prim connected to a string array connector you cannot create an array of strings, which would contain comma or newline. To create such a string you either need to use string array prim, array builder prim or Ruby.
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: String array bug

Post by tulamide »

Yes, KG, that's exactly why I call it a bug.

There is absolutely no reason to make a comma a seperator to split strings. It just doesn't make sense. A comma is an integral part of text, in any language. Control signs are the only seperators that make sense (newline, carriage return, tabulator, etc.)

For me it is either lazyness or inattention. The comma obviously is a relic from the text to float array conversion. But since the conversion type is known, it would have been not much more than branching a line of source code or two.
"There lies the dog buried" (German saying translated literally)
Post Reply