Why do I need New here?

I have a window with implicit instance turned off.
To declare the window I use the following code

Dim FLesSplash As New Splash(0)

I have to include New or the analyzer screams. Why??
The (0) is the constructor

Dim x as  variableofsometype

creates a pointer to an instance, but at this point it is ‘pointing’ to nothing… (= nil)

Splash(0) is calling a constructor/method of an instance.
It can’t work on a nil.

So you must create an actual object to call the constructor.
And you do that with new.

Dim FLesSplash As Splash //would work, followed by FLesSplash = new Splash(0)

Because :

Implicit Instance issues a “new” for you

a window is an object, and all objects need to be instantiated (with a very few exceptions)

Removing the New didn’t work. I tried it immediately rewriting the line (again).

Dim FLesSplash As Splash(0) FLesSplash = New Splash(0)
My problem is I want to use the method this is in with a thread, and I would like to have a splash.

It will take this if I remove the constructor and the window doesn’t need this for this instance.

Dim FLesSplash As Splash FLesSplash = New Splash
Is there a simple alternative to having this window?

why not leave Implicit Instance True
make Splash the main window, and use HIDE to move to you next window

Thanks. I’ll think about that. Might work

When you create a Window in Xojo, you might consider it being a custom Window subclass. That’s why you usually have to use New – only then a new instance is being created.

Because often a Window does not have to appear in multiple instances, Xojo created the convenience switch “implicit instance” which creates the instance automatically for you. But even an implicit instance window can still be created multiple times with a Dim New command.

You cannot touch any UI within a thread, even if the window pre-exists.

I sometimes call a method within an Error window to display the error from a String array, start a Timer to add it to the screen and makes the window visible. In the app Open Event I open and hide this window using WinHelp.Hide so I know it will be available if needed from a thread.

Thanks David
I figured out that if I put a MsgBox outside I can get the same results.

Just be aware that you cannot display a MsgBox from within a thread as you will get a UIExceptionError.

This blog post might help: https://blog.xojo.com/2013/06/24/accessing-the-user-interface-from-a-thread/