[Gambas-devel] gb3 Split() problem

Benoît Minisini gambas at ...1...
Mon Jan 4 12:51:06 CET 2010


> 2010/1/4 Benoît Minisini <gambas at ...1...>:
> >> Gb3 does not correctly split when the separator is a "\r\n" combination:
> >>
> >>   Dim aText As String
> >>   Dim bText As String
> >>   Dim aLines As String[]
> >>   Dim bLines As String[]
> >>
> >>   aText = File.Load("Text1")
> >>   bText = Replace(aText, "\n", "\r\n")
> >>
> >>   aLines = Split(aText, "\n")
> >>   bLines = Split(bText, "\r\n")
> >>
> >> The gb3 documentation states, "Separators is a list of sperators
> >> characters",
> >
> > That means that both "\r" and "\n" are separator characters. Split() can
> > only deal with one character separators.
> 
> But " \n" in the example is two characters; there is a space before
> the \n and the documentation explicitly uses the plural for
> separators, not the singular. It also refers to a "list", and a list
> implies more than one.
> 
> > To split between "\r\n", you must write your own function.
> 
> I'm ok with that answer because I can deal with it in code, but what
> you are saying is that "Separators is NOT a list of sperators [sic]
> characters", but that the "Separator is a single character".
> 
> Is that correct?
> 

Yes, I have added an explicit warning to the Split documentation, as 
apparently it was not clear enough.

Regards,

-- 
Benoît Minisini




More information about the Devel mailing list