Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

When to use read events 1

Status
Not open for further replies.

Judi201

Technical User
Jul 2, 2005
315
US
Hi!

I decided that I could see no need for a menu in the program I am rewriting from old dos FP to VFP 6.0 so I am trying to use a main form as my startup. If anyone has reasons not to do this I would appreciate hearing them.

I created a MAIN.PRG with SET ,DEFAULT, PATH, etc.
Then DO FORM MyMainForm follow by READ EVENTS

When I run MAIN.PRG, the FORM MyMainForm is not displayed.
If I step through it in debug it is displayed!!! Why??

I removed the READ EVENTS and it runs from the MAIN.PRG.

I was using craigsboyd's answer in thread #1085137 as a guide in looking for the solution and tried another form, a top level form, so I am thinking that I have set something somewhere that is causing the behavior.

Would someone please explain the use of a Top Level form and is that the form that you want to be the first displayed or an additional form.

As I said, the form loads without the READ EVENTS but it will not call other forms as I need it to do.

ANY help will be appreciated.

Judi
 
Hi Mike,

I found ON SHUTDOWN QUIT is the way to suppress the "Visual Foxpro cannot quit" message, even though you are right that QUIT alone in an error handler triggers that message.

Code:
ON KEY LABEL ALT+F1 Error 1
ON ERROR QUIT
oForm = CREATEOBJECT("Form")
oForm.show(1)

Run and trigger an error by pressing ALT+F1 => Message "Visual Foxpro cannot quit"

Code:
ON SHUTDOWN QUIT
ON KEY LABEL ALT+F1 Error 1
ON ERROR QUIT
oForm = CREATEOBJECT("Form")
oForm.show(1)

Run and press ALT+F1 => foxpro quits (including the IDE).

I'm not sure however, if the same behaviour as the QUIT within the error "handler" (or non handler), will occur if you use the QUIT command within a routine you call by ON SHUTDOWN.

And it seems the QUIT from the second example triggers the ON SHUTDOWN event and the second QUIT really quits (!?), or why else would the ON SHUTDOWN setting in the second example have any influence?

finally the same with READ EVENTS:
Code:
ON SHUTDOWN QUIT
ON KEY LABEL ALT+F1 Error 1
ON ERROR QUIT
oForm = CREATEOBJECT("Form")
oForm.show(2)
READ EVENTS

It's not a real life example and I can imagine certain things to prevent ON SHUTDOWN QUIT, like message boxes or report preview windows.

Let's see...

Code:
ON SHUTDOWN QUIT
ON KEY LABEL ALT+F1 Error 1
ON ERROR QUIT
Messagebox("test")
ALT+F1 => having no effect at all...

So maybe it's a good idea to give every messagebox a (high) timeout to prevent a vfp app hanging when wanting a forced exit (triggered by some flag file or record read by a timer).

Bye, Olaf.
 

Olaf,

That's very interesting. Thanks.

For what it's worth, in my own apps, I have the ON SHUTDOWN call a generic close-down routine which does things like checking for unsaved edits, and which eventually issues CLEAR EVENTS. Control then passes to the line after the READ EVENTS, which is where I eventually issue the QUIT.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Hi Mike,

if you try this:
Code:
ON SHUTDOWN messagebox("no way!")
QUIT

then QUIT will really trigger the messagebox.

So it may be a good idea to issue ON SHUTDOWN QUIT at least before using the pure QUIT, if you want the QUIT to quit and not to (re)trigger your ON SHUTDOWN routine...

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top