Page 1 of 1
String array bug
Posted: Sun Dec 06, 2015 2:27 am
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.
Re: String array bug
Posted: Sun Dec 06, 2015 3:23 am
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.
Re: String array bug
Posted: Sun Dec 06, 2015 8:14 am
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.