Got a compilation error in StringToArray

Startbeitrag von King am 13.04.2010 09:14

Hi All

StringToArray is a beautiful function but I received a compilation error, it said
"No Syntax of StringToArray is compatible", see code as below:

sMyValues is string = "A B C D E"
// Initial array
MyArray is array of 5 strings
MyArray[1] = "Y"
MyArray[2] = "X"
StringToArray (sMyValue,MyArray,[" ", " "])
info(MyArray[5])

// it works without [,] but it returns 6 elements instead

Is it a bug? Any clue??

King



Antworten:

Hi King,

Try removing the square brackets.
In the Help they mean the parameter is optional.
For a one-dimensional array just one parameter is necessary for the separator.
BTW you don't need to assign any values to the array, since they will be overwritten.

Regards,
Piet

von Piet van Zanten - am 13.04.2010 10:03
Nope, it only filter one space and there's no OR case. It sounds like it's a bug !!!


von King - am 13.04.2010 20:24
Hi King,

This code works fine:

sMyValues is string = "A B C D E"
MyArray is array of 5 strings
StringToArray (sMyValues,MyArray," ")
Info(MyArray[5])

Like I said, just don't use the square brackets [ ], it's only a convention in the help to indicate optional parameters.

Regards,
Piet

von Piet van Zanten - am 13.04.2010 20:56
Hi King,

In your example the correct call would be:

StringToArray(sMyValues,MyArray," ")

It works correctly here (WD14).

Kind regards,
Alexandre

von Alexandre Leclerc - am 13.04.2010 20:57
Alex

sMyValues is string = "A B C D E" //

von King - am 13.04.2010 23:59
What do you expect, it's a programming language, not artificial intelligence. ;-)
Indeed, use replace to normalize your data.

Regards,
Piet

von Piet van Zanten - am 14.04.2010 05:48
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.