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
FontListBox.RemoveAllRows
for counter = 0 to myFontCount -1
theFontName = system.FontAt(counter)
if theFontName.IndexOf(searchString) >=0 then
fontlistbox.AddRow(theFontName)
end if
next
else
FontListBox.RemoveAllRows
for counter = 0 to myFontCount -1
FontListBox.AddRow(system.FontAt(counter))
next
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?
Thanks
Donald
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.