Loop question

I am making my way through the Introduction to Programming with Xojo I’m working on Loops. Yep, I put the beginning in beginner. On section 3.8 page 58 (Working with Loops) I have been instructed to enter this code:

var searchString, theFontName as String
var counter, myFontCount As Integer

myFontCount = System.FontCount

If me.Value <> “” then
searchString = me.Value

for counter = 0 to myFontCount -1
theFontName = system.FontAt(counter)
if theFontName.IndexOf(searchString) >=0 then
end if
for counter = 0 to myFontCount -1
end if

It works so that isn’t a question. I have been fiddling around with the code trying to figure out exactly what each part does. It’s the code after the “else” statement that has me baffled. I’m not sure what it’s doing. If I comment it out and run the project it all seems to operate correctly. So… what is it doing?



P.S. I want to make sure. I do understand that the “else” happens if the first part doesn’t. I just can’t seem to trigger the conditions where the else part is executed. That is why I say I don’t understand what it’s doing.

The else condition is triggered when you have changed the contents of the search field and the result is empty. Eg., type in “a” and then hit Backspace. That will trigger the Else condition.

What it does is simply list ALL the fonts, instead of just the ones that match what you typed in. In other words, if your typing results in an empty field, then you see everything instead of a filtered list.

Thank you. I got it now. :grinning: