Enumerations Wonky?

Am I having a brain freeze or are enumerations wonky?

In the App class I define a public enumeration :

Public Enum PathStatus Quit MissingFolders HasFolders End Enum

In the default window open event I do:

Sub Open() Dim X as App.PathStatus X = App.PathStatus.MissingFolders End Sub
And App.PathStatus autocompletes as expected as does App.PathStatus.MissingFolders

BUT when I run I get the error :

This Item does not exist X= App.PathStatus.Quit
where the highlighted portion is <X= App.PathStatus>

So is this a a huge bug or am I forgetting something obvious?

  • Karen

Reserved word maybe? Try it without the quit.

LOL… 10 seconds to late… was about to say same thing

Not it… I changed it to QuitChosen and still get same error

Nope
Makes perfect sense

You have one of two alternatives

  1. rename your app subclass (try myAPP) and use
    Dim X as App.PathStatus
    X = myApp.PathStatus.MissingFolders

  2. use X= PathStatus.Quit in method in the app class

In code APP is a METHOD that returns the singleton instance of your App class
http://documentation.xojo.com/index.php/App

It’s more than that… i moved the enum into a window set it to public but accessing it via
Dim X as WindowName.Enum gives me not exists error… So I gave up and am using integer constants!

A Window will have the exact same problem when ImplicitInstance is turned on, for the exact same reason. The window name is a method that returns the singleton for that window.

Thought I had turned off implicit instantation… but I had not… that should be off by default for new projects!!!

Yeah, I personally hate implicit instantiation. I hate implied behaviors in general. I almost filed a feature request for a preference to turn it off by default, but it’s a setting that feels more appropriate on the project level rather than the preference level. Since settings like that don’t exist, a feature request feels kind of futile.

Perhaps changing the default template will help a little. Still creating a new window has implicit instance turned on by default.
So, project settings would be very helpful, but in lacking of this, a global preference would be good.