Updated: Make Your Own Classes Iterables - Discussion

Continuing the discussion from Updated: Make Your Own Classes Iterables:

I’m not sure if this was intended or not, but the downloadable example project is the API 1.0 edition and doesn’t match the article.

Another main difference is that you cannot continue through the loop if an exception is raised, unlike when using For… Next, see <https://xojo.com/issue/63699>


Just looking at the description of the Feedback case and the example. What is supposed to happen in the example? I clicked on the button… and nothing happened. Ok, so c:windows isn’t the best starting point for macOS. But even with specialFolder.Applications as starting point: what should I see?

You’ll only encounter the problem if a file in your search path isn’t accessible at which point an exception is thrown that you can’t iterate past, hence iterables being of limited use when exceptions are encountered.

Still confused. Isn’t that the purpose of the try/catch? And how does that differ from not using an iterable? What does “isn’t accessible” mean?

In the example, it would be a file that doesn’t have correct privileges to access it, or the file has been (re)moved since the directory listing was obtained and the iterator hit the file.

If the internals of the iteration raise an exception, you cannot skip and carry on. If you break the iteration out into a standard for loop, you can indeed use try/catch as you can handle the skip and carry on yourself, thus rendering the use of iteration limited.

See Folder Contents in a Menu – Xojo Programming Blog where I first encountered the problem, raised it Latest Blog and Announcement - Folder Contents in a Menu - General - Xojo Programming Forum then the changes needed in Folder Contents in a Menu, Redux – Xojo Programming Blog

Hi there,
i’m making it a little easier a class as a record and an array as a list for the output old programming


Is this related to the topic?

I would say this is the correct way to handle such a situation. Am i wrong?

No, you are not wrong. As the article was revisited I thought it pertinent to mention.

1 Like

There’s something else I quite don’t get in the announcement.

Why would one add and use an iterator to get the addresses when it’s simply doable with “for each Address as PostalAddress in ThisPerson.Addresses”, since ThisPerson.Addresses is already an array (so, iterable)?