Xojo returning returning incorrect Type when calling .addRow method

Sorry for the newbie question, but I’m working through the Introduction to Xojo book and am stumped on Chapter 3.8. When I try to Run the code I am getting an error that states, “Type “TextField” has no member named “AddRow” Me.AddRow(Font(Counter))” when I am adding the Open action to the FontListBox field.

I have triple checked to make sure that the control type is a ‘FontListBox’ and not ‘TextArea’ or something else and am 100% sure it’s correct.

Ignore the last 3 errors

http://i.imgur.com/VJbN5j7.png

Sorry if my terminology is incorrect, I’ve only been using Xojo for a few hours

It worked fine on my work computer (mac) but when I went to re-create the project on my home computer (PC) I get this error

http://i.imgur.com/Alqxh9R.png

TextField indeed does not have an addRow method. You probably got mixed up between

TextField : http://documentation.xojo.com/index.php/Textfield
and
ListBox : http://documentation.xojo.com/index.php/ListBox

Apparently what you want to do is to add fonts to a listbox.

See the example at http://documentation.xojo.com/index.php/Font

But look at the icon, it’s a Listbox, as says the Super field. Very odd. And why is “Counter” flagged?

My guess is these errors are spurious, instead some error in the unfinished SearchField code is spilling out. I mean how is the Open event declaration giving a syntax error? Try commenting out the code in SearchField and see it the errors remain.

Posting code is the only relevant way of getting adequate assistance. I did not want to say anything about his pictures, as I consider this quite unproductive. But since he is a novice, I shall make an exception.

From the little posted, I see counter being invalid, that is what creates the second error. So he should first properly dim counter, and the addrow thing will go away.

That’s the thing, how is counter not dimmed correctly? The shown code and types look ok to me.

this is wrong in the first picture :

dim counter myfontcount as integer

I guess the OP has tried to overlook errors instead of fixing them in the order they appear. The second picture is kind of frightening in that respect.

Oh, I see a comma there

dim counter, myfontcount as integer

[quote=234655:@Will Shank]Oh, I see a comma there

dim counter, myfontcount as integer

See ? We are wasting time playing detectives around a picture showing errors, instead of analyzing the code.

This is futile in the extreme.

@James Gill : Please post the complete code that triggers the errors, in addition to the error pictures. Don’t be shy, we all started one day. Make sure to hit the “Code” icon above the editor, that looks like a document with <> before you paste the code, so it is more readable.

I assumed that by at least posting screenshots of the ‘code’ that would do enough, but obviously not. Is there a doc that explains in what order Xojo actually runs code? (Event Handlers, etc, etc. I have no idea what I’m talking about here so any help is appreciated)

Since it APPEARS that the errors are listed from the bottom to the top in the Errors list, can I assume that the parts of code at the bottom of the Errors list are happening first and therefore need to be resolved first? If so, the FontListBox control has two Events associated with it, Change and Open. If again, I assume that they are run in the order that they are listed, than I can skip ‘Change’ since I don’t see any errors and see that there are two errors listed in the ‘Open’ Event, so here’s that code:

[code] Dim counter, myFontCount As Integer
myFontCount = FontCount

For counter = 0 To myFontCount -1
Me.AddRow(Font(Counter))
Next[/code]

The two errors in that code state,

'Redefined identifier. This name is already defined by variable Counter (Dim Counter, myFontCount As Integer'

and

Type "TextField" has not member named "AddRow" Me.AddRow(Font(Counter)).

Incidentally, is there any way to copy errors to clipboard so I don’t have to type them out?

Anyway, the first error I’m at a loss at since I’m still not too familiar with Xojo, but the second error is what has me confused the most. The Me.AddRow object is clearly listed as a ListBox and not a TextField in the Inspector and even given my extremely limited knowledge of Methods in Xojo, the FontListBox Control is a ListBox and not a TextField as referenced in the Inspector.

Edit: Oops, I marked my response as an answer and I have no idea how to undo that, oh well.

This error will happen if you have something like:

Dim counter, counter As Integer or Dim counter As Integer Dim counter As Integer or Dim counter As Integer For counter As Integer = 0 To ...
.

This means that you’re code is in the Open (or another) event of a TextField instance in your window:

Me.AddRow(Font(Counter))

TextField has no AddRow method. You can use AddRow only in a Listbox or PopupMenu.

Rename counter to something like myCounter and see if the error still occurs. My guess is that you have already defined it somewhere else. Otherwise the code looks okay, counter is not a reserved keyword.

Yes, that is very weird. As is “Counter” being flagged as a repeat. Both of those don’t make any sense.

Have you tried commenting out all other code? Sometimes an error in parsing will spill over into other places. That’s my suspicion here since the FontListbox.Open Declaration is marked as a Syntax Error. That isn’t code you have anything to do with.

Maybe try rebuilding the tutorial in a fresh project or post this one that’s causing trouble.

No, it doesn’t work like that. There’s no execution order between methods/events but errors within a method are usually (always) listed from top down.

But that shouldn’t be an error !?