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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The ".exe" runs and closes after a build 4

Status
Not open for further replies.

FoxEgg

Programmer
Joined
Mar 24, 2002
Messages
749
Location
AU
The ".exe" runs and closes after a build ...I can see it flash up then it is gone....

Anybody help..


Thanks

John
 
and read about the counterpart: CLEAR EVENTS.

Don't worry. That's a typical mistake and once
you know it, you'll like the ease of putting
the "wait for events" loop anywhere you like.

If you don't build the exe and run your app
in the IDE it works, right? Have you noticed
that the command window is open and the cursor
is waiting there for your commands? The reason is,
that the IDE now makes up the event loop and if
you compile and run the exe there is no halt
and so the app disappears as soon as it's there...

Bye, Olaf.
 
Thank you both...

I put the READ EVENTS command in the Init Event of the only Form in the whole project... it kept the window open... but showed nothing... and I had to Cntrl alt del to get out of it...

I read the read and clear events.... doesn't say where to put it

Stars bequested...

Thanks

John
 
Hello FoxEgg,

thanks for the Star.

A little more to clarify the usage and the effect of READ EVENTS:

when READ EVENTS is executed this halts execution of further code until CLEAR EVENTS triggers to get back to READ EVENTS. What doesn't halt is the processing of windows events, such as button clicks etc.

So if you put READ EVENTS in the init of your form, that will stop execution of the Init method and so the form will not show up.

You should have a main.prg where you start your form, probably with DO FORM ... Put READ EVENTS after this call of the form, not within the form.

You can put CLEAR EVENTS in the Unload of the form and then foxpro will continue with what comes after READ EVENTS, when the user exits the form. That could be CLOSE DATABASES ALL and some more...everybody you ask does something different there.

If you have a complexer application with more forms and
a menu and/or toolbar the CLEAR EVENTS is best put in the File->Quit or in an Exit-Button on the toolbar.

Where to put the READ EVENTS depends on when you think your applilcation is "ready to go", which is not in a forms init and not in the forms activate event either
(because that is triggered everytime the form is activated).

By the way you can also live without READ EVENTS in a single form application if you set that form to be modal
(Windowtype = 1). Then foxpro will continue after DO FORM only when the form is closed.

Bye, Olaf.
 
Let's say you're creating a basic project...it consists of a single program file "main.prg" and a single modeless form "form1.scx". You have your main.prg set as main (right-click on the file in the project manager and you can set it as main - you can tell which file is set as main in your project because the name of it will be in bold print). Now in your main.prg you have the following lines
Code:
On Shutdown Do ProperShutdown
Do form form1
read events

Procedure ProperShutdown
on shutdown
clear all
close all
if _vfp.startmode = 0 && are we running in VFP IDE?
     cancel
else
     quit
endif
endproc

...and in either the unload event or the destroy event of form1 you have the following
Code:
clear events

That's the basics of it. Read events starts the process loop for user events and will continue there until a "clear events" is issued. ProperShutdown is code that will run whenever you shutdown your application, even if you were to terminate the application from the task manager using "End Task".

boyd.gif

 
Thank you VFP people... It was indeed my first .exe and having plaigarized your recommendations... it worked and I can now teach my daughter (and hence look like I know wht I am talking about)

I am genuiely very very grateful

John Fox(Egg)

By the way... Ramani just recently gave me this advise when I was having (what I thought was unrelated) database closure problems...

******************************************************
ramani (Programmer) Oct 19, 2004
HI

In addition to the points mentioned above...

1. If your compiled EXE is having problem, then it is likely that you have built the executable including the data files. You have to exclude the data files from the project compilation. For this... simply right click on the table in the project and choose exckude. You will get a stop simbal placed next to the table.

2. In a development environment.. You run the execute with your project closed.. or atleast with the active tab of project not in Data tab. Data tab opened displaying the tables, often make VFP open the tables involved and so exclusive usage becomes not possible. I have faced this often. If you open the project on a tab other than data will not throw that error.

*****************************************************
Do you all think the right thing is to exclude the data files ?

Foxy
 
Hi Foxy,

If you include the data files in the build they become Read Only. If you need to modify the data it must be excluded.

Regards,

Mike
 
Well that answers that quite comprehensively... a "VFP slam dunk", I would say.

Thanks Mike

John Fox

And so that bringeth us to the close the FoxEgg's lesson on .exe files...

For all who helped ..I thank yee.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top