Split Function not working exactly as per wiki documentation

According to the wiki documentation…“The required parameter, string, is a valid string expression; if string is a zero-length string (""), Split returns an empty array.” This doesn’t seem to be the case! See sample Basic Code below. If you un-comment the Line where the Split function is being called, you will notice that the UBound Function no loger returns -1 (and the DataSet.length will be 1 insead of 0). In Fact, what is returned is an array containing an empty string. eg. DataSet[0]; which is not the same as an empty array.

This issue has resulted many hours of debugging some code where I was using the result of the UBound function in a For… Next loop; as in the example below.

Hope this helps anyone else who has been using the Split and UBound functions together; as I have.

Dim DataString   = ""
Dim Delim        = ","
Dim DataSetCount
Dim DataSet
Dim i

DataSet = Array()

//DataSet = Split(DataString, Delim)
DataSetCount = UBound(DataSet)  

If DataSet[0] = "" Then Print "Empty DataSet[0]"
Print "DataSet.Length = " & DataSet.length & vbCRLF & "UBound(DataSet) = " & DataSetCount

For i = 0 To DataSetCount
  Print "This message should NEVER be displayed"
Next

Regards,
Robert Suranyi

Good catch. The documentation was incorrect: it has been fixed.

The mistake in the docs has been there since AppStudio was released in 2010. In fact, it goes back much further than that: the same mistake was in the NS Basic/CE docs, back in the last century.

Thank you for reporting this!