I use a window to replace the MessageBox. In that window I have a timer that goes off at the end of the open event. All of a sudden the timer is a NilObjectException. I use this in many places so I know this code works. In fact about 20 seconds before this same window appeared with a different message.
This is the line of code with the NilObject
WaitforOpen.RunMode = Timer.RunModes.Single
I tried adding
WaitforOpen.RunMode = Timer.RunModes.Off
but that didn’t change anything as I still get an error.
Since this has never happened before, I’m thinking it might be that the window isn’t completely destroyed and I need a destructor.
Is the window an implicit instance or are you instantiating it manually? The window will not go NIL after you call the Window.Close if that is what you are running into. Normally I don’t use implicit instances and I have the window property on another window or module that I would make NIL on close.
Yes. It’s manually instantiated.
I tried looking for docs related but I couldn’t find them
Try adding: ModuleOrOtherParentWindow.yourWinVar = NIL in that instantiated window’s close event.
I don’t understand. What is Nil
It resets the class back to nil or no-value. (I do this all the time btw)
The name of the window is BoxMssage and the timer is WaitForOpen
If I put either with an = Nil in Close I get an error message
I understand “it” is a module but I’m not sure which is the module.
Where is the property for your instantiated window located? Can you drop me your test project and I can show you also?
It’s in the other window, That would mean I pass the window and then set it to Nil from this window
That was wrong. Not a window.
Part of the problem is it is in Modules.
The only time I use this is if it is NOT in a window.
Send me a sample project - Ill show you as its not translating well in text. I was using Window/Module as an example.
location.thisWinProperty = nil
This will reset your window property and allow your code to reinstantiate it on another run which should help or fix your situation. I just need more context to help efficiently.
I’m glad you suggested create a project. I got an error on the timer before closing.
Ok - You are using implicit instance on your windows so my above comments are moot.
It appears that you are using:
Self.ShowModal() which is causing an issue in the BoxMessage.Open event. This is preventing the timer to run before a user presses a button. It looks like you are trying to keep this window open so the Timer will continue to run? Is this correct?
When I change to Self.show it appears to work, but Im not sure its the intended result.
I just noticed that. I am going to have think which I wanted since I have constructors which to me mean not implicit.
I’m using the timer to make sure it shows up on top.
Can you provide a small paragraph about what you want to have happen overall? Perhaps I can help make some suggestions after that?
I think I’m okay. I’m sure it is supposed to be explicit.
I have a different problem now. Since it’s explicit, I can’t use BoxMssage.show to pop it up. A whole lot easier than finding a setting off.
.Show runs Async (thread isn’t held) and .ShowModal runs in Sync (Thread is held meaning no other code runs until your box is closed).
I still don’t get why the timer showed as NilObject.
As to ShowModal. It doesn’t always mean it is on top. I think with PC it can be hidden. Maybe Mac.
I made the window a single instance, Bmsg. Then added to the close event Bmsg = Nil.
Setting Bmsg to Nil didn’t do it.
I am still getting a NilObject on the second call.
Could you update the sample for this so I can check it out? On this one Ill rewrite where I see issues if you are ok with that.