More than one item

Context: Mac / Xojo 2016 Release 1.1

I have a TEXT constant of the window labeled TA_INFO

This code results in an error message:

[quote]Dim axOneLine() As Text
axOneLine = Self.TA_INFO.Split(EndOfLine)[/quote]

The line

axOneLine = Self.TA_INFO.Split(EndOfLine) throws an error message

Error Message:
There is more than one item with this name and it’s not clear to which this refers.

After stumbling around trying to understand what this error message is trying to tell me, I can “fix” this problem with the code below

[quote]Dim axOneLine() As Text
Dim LF_Text as Text
Dim LF_String As String
LF_String = EndOfLine
LF_Text = LF_String.ToText
axOneLine = Self.TA_INFO.Split(LF_Text)[/quote]

But I still not not understand what that error message is all about and why the line

axOneLine = Self.TA_INFO.Split(EndOfLine)

throws an error

axOneLine() is an array?

axOneLine.Append (Self.TA_INFO.Split(EndOfLine))

SPLIT returns an array of STRING not TEXT

axOneLine() is indeed an array.

You can alternatively write this as

[quote=264038:@Axel Schneider]axOneLine() is an array?

axOneLine.Append (Self.TA_INFO.Split(EndOfLine))[/quote]
Append takes a single value, not another array.

The docs say Text.Split returns an array of Text.

EndOfLine is a String, not a Text. That is probably what is confusing things. Try something like

axOneLine = Self.TA_INFO.Split(EndOfLine.ToText)

Is not allowed for whatever reason. I am not sure why not but that is why I go through the contortion of

[quote]Dim LF_Text as Text
Dim LF_String As String
LF_String = EndOfLine
LF_Text = LF_String.ToText[/quote]

EndOfLine.Unix.ToText or EndOfLine.Macintosh.ToText ought to work, depending on your needs.

EndOfLine is a class NOT a constant since you cannot have a constant that has named members

Original Poster wrote:

"But I still not not understand what that error message is all about and why the line

throws an error"

Ultimately the reason for the error is that someText.Split(someParameter) expects someParameter to be Text not a String. EndOfLine returns a String. You have to make sure that what you pass is a Text variable not a String.

You might think that you could get away with passing EndOfLine.ToText but you cannot. EndOfLine is itself a Class and not a String variable and the construct EndOfLine.ToText is not allowed.

It is possible, as Lefebvre pointed out, to pass EndOfLine.Unix.ToText because EndOfLine.Unix is a String and EndOfLine.Unix.ToText makes it Text.

So we have established that

is erroneous.

The actual error message that you are given to work with is
“There is more than one item with this name and it is not clear to which this refers”

That is not a very helpful error message. At least for me.

Consider the number of different reasons this error message is displayed…

In other words: you got an error message, try to figure out why (guess ? Bet ?) ;-:slight_smile:

Even for native English speakers this message is not very intuitive.

In general that message appears when the types do not match. But indeed it is not very informative.

did not you define another Split function ( using an extends keyword or for another data type) ?
this messages occurs sometimes when I have such multi definition for the same method.

Pochez asks:

[quote]did not you define another Split function ( using an extends keyword or for another data type) ?
this messages occurs sometimes when I have such multi definition for the same method.[/quote]

No, nothing like that. It is simply the presence of a String variable as a parameter when Xojo expected a Text variable that triggers this error message in this case.