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

Create a "Simple" App/EXE

Status
Not open for further replies.

gguerra333

Programmer
Sep 21, 2012
19
US
I need to build an EXE from a simple PRG. Is there a way to build an application without a form. I need it to run at specific intervals (using windows task scheduler) update some tables and then exit. I have tried doing it with a form and placing the code within different methods. The init method opens the tables but as far as the actual code to update the tables I have tried putting it in the activate, refresh, show etc methods and no go. I even tried placing one command button on the form and still nothing. I need the program to run without user intervention and exit/quit automatically.. Any ideas anyone?
 
A single prg is fine to build an EXE from it. Why hesitate, simply do it. What makes you think you need a form?

Bye, Olaf.
 
As Olaf said, you can build an EXE from a single PRG.

You need a project, and you either need to make the PRG the first item added to the project (so it's automatically set as main), or you need to Set Main after the fact.

There's no need for a form at all. If you WANT a form (to display progress, for instance) then that can be called from your PRG, but it's not a requirement.
 
You might benefit from taking some time looking over the free on-line VFP tutorial videos at:
Some of them that might be of particular interest to you could be:
Building a Simple Application - Pt. 1
Building a Simple Application - Pt. 2
Building a Simple Application - Pt. 3
Building a Simple Application - Pt. 4
Building a Simple Application - Pt. 5
Building a Simple Application - Pt. 6


But, as Olaf says above, depending on what you want the application to do and how you want it to interact with users (if at all), you might not need a Form at all.

It could be as simple as: Create a Project and then Add the PRG file and Build the Project into an EXE.

Good Luck,
JRB-Bldr
 
Gguerra333, the others have given you a good answer. I would only add that you really don't need to sit through the videos that JRB-Bldr suggested. This is not to denigrate the videos in any way. But the answer is very simple, as Olaf and Dan have explained, and it will take you much less time to just do it than it would watch even one of the videos, let alone all six.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Well, go.

I want to go back to my question "What makes you think you need a form?". It's not meant as rhetorical question, if you find that somewhere said in the help it should be corrected, for example.

It's even easier as Dan suggests, you can

Build Project yourproject FROM your.prg

and then

BUILD EXE FROM yourproject.

That's all needed.
Or you could also do one EXE calling any prg as
LPARAMETERS tcProgram
DO (tcProgram)

Put that into a prg and it will be the only prg you would need to turn into an EXE to call any other PRG.

Bye, Olaf.
 
Thanks guys.. I was away for the weekend.. I guess I would like a form to display status and messages but the form does not need to have any controls on it. (No user intervention). I will DEFINE WINDOW and ACTIVATE WINDOW plus do some WAIT WINDOW commands to display status. Thanks again. Will post back if any difficulties.
 
No, you don't need either DEFINE WINDOW or WAIT WINDOW.

Design your status form with the form designer and call it from your main PRG. It'll be far less effort!
 
I would like a form to display status and messages but the form does not need to have any controls on it.

As has been said, you do not need a VFP Form to do that.
You can do with WAIT WINDOW's within your PRG.

Good Luck,
JRB-Bldr


 
OK I created a very simple PRG for testing purposes and it runs fine in VFP but when I build an EXE and run it from Windows desktop I only get the WAIT WINDOW messages to show. The defined window is never displayed. Am I missing something?

This is my simplified code

DEFINE WINDOW ptup FROM 5,5 TO 50,50 IN DESKTOP DOUBLE TITLE 'Update'
ACTIVATE WINDOW ptup IN SCREEN
? "Update in Progress...." FONT "Arial",10
WAIT WINDOW "Hello 1" TIMEOUT 3
WAIT WINDOW "Hello 2" TIMEOUT 2
WAIT WINDOW "Hello 3" TIMEOUT 1
RELEASE WINDOW ptup
CANCEL
 
I haven't cared much for WAIT WINDOW since the advent of Windows(TM). Nothing screams "THIS IS A FOXPRO APPLICATION!" like a wait window.

Not that there's anything wrong with that, but it's so un-Windows(TM) it really sticks out. Plus, if you use SCREEN=OFF (which you typically would for the kind of app being discussed here) you can't use WAIT WINDOW anyway because it happens "in" _Screen.
 
I think you are referring to the simple WAIT command without the WINDOW clause as being a "THIS IS A FOXPRO APPLICATION" type command.. There is nothing wrong with a WAIT WINDOW as it simply displays a message in a window and goes away automatically, but anyway that is not the point. The window defined with DEFINE WINDOW never displays at all. The WAIT WINDOW commands are there to show me that the thing is running, that is all. If it was not for that I would get nothing.. My problem is the user defined window never displays even if I add DEFINE WINDOW IN SCREEN. So I tried DEFINE WINDOW IN DESKTOP and still nothing. I am running from the desktop (XP) without any other windows open and all I get is the "Hello" messages and all of my desktop icons.
 
Never mind I found the problem. I had SCREEN=OFF in my config.fpw. That was it, thanks.
 
You define a window, fine. But you need show window to show it.

Or you simply create a form and DO FORM, and it's defined and showed...all at once ;)

If already two experts tell you to use a form, why insist on a define window being better? If you would say you're used to this old style, I'd be fine with that, but you don't even seem to know the basics in that old foxpro style. Then go for a form, that is not only more modern, but also easier for beginners, as it's visual and doesn't need much programming.

Bye, Olaf.
 
Hey Olaf, try reading before you assume things. I wanted an EXE WITHOUT a form if you would read. Not only that the ACTIVATE WINDOW "Displays and activates one or more user-defined windows or Visual FoxPro system windows" . This is right from the VFP help. Look it up.

 
Your needs have changed within the thread, haven't they? Didn't you wrote "The defined window is never displayed. Am I missing something?"
You're right that ACTIVATE does not only activate but also shows a window, but SHOW WINDOW also shows windows.

Bye, Olaf.
 
Well it seems that the SCREEN=OFF in the config.fpw (and in the project) prevented the user defined window from being displayed, BUT with without it I get the main foxpro window which I don't want either. I simply want a window that opens when the program runs, updates some tables, displays some status messages and then exits all without any user intervention.
 
It seems that Application.Visible = .F. is available when using forms but again there is no form here. I could just leave the main foxpro window and issue _screen.caption="Whatever" and SET SYSMENU TO. Anyway its just aesthetic and not that important either way but if anyone has a better suggestion I would appreciate it.
 
Ah, ok.

Even if you define a window as IN DESKTOP it's a child window of _vfp. That means GetParent(yourwindow.hwnd)= _vfp.hwnd. That makes it's visibility depend on the _screen visibility.

Well, you have two options: the _screen itself, on which you can show messages with ?, simply set _screen.font to a prettier font than Courier. Or a form with ShowWindow = 2. Put a label on that form, for example, and then do:

Code:
DO FORM yourform NAME oOutput
*do stuff
oOutput.label1.caption = "message1"
* do stuff
oOutput.label1.caption = "message2"
* do stuff
oOutput.release()

Or put an editbox inside the form and add output text to it's value property.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top