Method parameters

Working through the introduction to programming.
On page 66
Did this:

  1. Navigate to the FillFontListBox method and enter this into the Parameters field:
    searchString As String

Page 67 read this:
Every parameter needs to have a name and a data type, just like a variable. In fact, you can think of a parameter as a variable that can be used inside the method. If necessary, toggle the disclosure triangle next to the line that says, “Sub FillFontListBox” at the top.

There is no Sub FillFontListBox at the top. The only thing that has a disclosure triangle is Method Name FillFontListBox

Without setting whatever this is, if I run the program, I get "Not enough arguments: missing String value for parameter “searchString” FillFontListBox

Lost…

Method and sub mean the same thing (a method is a subroutine), so “Method Name FillFontListBox” is what you are looking for. You need to enter searchString As String as a parameter for that method.

The distinction between sub and method isn’t really there in Xojo anymore. So the method FillFontListBox is what you want.

In Visual Basic and dialects you had (have?) both methods and subs. A function returns a value, a sub doesn’t. In Xojo you only have methods.

OK. So I just needed to read down further to see that error was expected, but I still have no idea what the book is talking about with a disclosure triangle next to the line that says, “Sub FillFontBox” at the top, since there is nothing like that there.

Again, ignore the word “sub”. Just go to that method and add in the string parameter as instructed and it should work.

My code is this, per the book:

Dim counter, myFontCount As Integer
myFontCount = FontCount

FontListBox.DeleteAllRows

If searchString <> “” Then
For counter = 0 To MyFontCount - 1
Then If InStr(Font(counter), searchString) > 0

FontListBox.AddRow(Font(counter))
End If
Next
Else
For counter = 0 To myFontCount - 1
FontListBox.AddRow(Font(counter))
Next
End If

But it gets a bug here:
Then If InStr(Font(counter), searchString) > 0

and here

End If

What’s wrong with the syntax?

What error do you get?

The keyword ‘Then’ is expected after this if statement’s condition
If searchString <> “” Then

Syntax error
For counter = 0 To MyFontCount -1

Syntax error
End if

Then If InStr(Font(counter), searchString) > 0

“Then” is at the wrong end of this line.

That fixed it. Thanks. The book has it in the wrong place.

One more question arising from the book. In a Text Field what property allows the text to wrap within the box?. I don’t see one in the inspector and it isn’t explained in the pdf book that I could see.

“Standard” TextField is a one liner by default.

TextArea is multiline (and styled, and…).

Edit (LR):
http://documentation.xojo.com/api/deprecated/textedit.html:

[code]Notes

TextEdit is the base class for both TextArea and TextField. TextEdit is an abstract class and it is not intended for instantiation. Use TextArea for multiline and styled controls and TextField for single line text fields.[/code]

Also: if you use Xojo 2019r2, beware of the Introduction to Programming with Xojo book: it works for the previous version.
At last, you have example projects with the download: that may help you.

Its modification date is May 31st, 2017. Things changed in two years.

Thanks. They snuck that TextArea in there without actually mentioning it and its purpose.