Yesterday, I posted a screenshot of my scariest error message. It was a message I had gotten while playing with the Desktop Alerts. Randy Jean commented that he saw the same error with the Desktop Alerts.
In the Alert class nResult_Assign() method, I had the Alert calling its Release() method. So, if you had code like this:
oMgr = CreateObject("VFPAlert.AlertManager") oAlert = oMgr.NewAlert() oAlert.Alert("Howdy") oAlert.Alert("Howdy Again")
The first Alert() works just as expected.
The second Alert() causes the “Catastrophic Failure” message. Why? Because oAlert had RELEASEd itself. And here I am, sitting with an object reference (oAlert) for which theVARTYPE() function returns an “O”.
One way to see if the Alert still exists is to check the Alerts collection Count property. In the above example, this would be something like:
lnAlerts = oMgr.Alerts.Count
If you look at the Alert class Release() method and comment out the RELEASE THIS line, you can then “reuse” the alert as many times as you want.
This post originally appeared on the Foxite Weblogs site.