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

MS FoxPro for Windows 2.5a - creates bad EXE's 1

Status
Not open for further replies.

millsrs

Programmer
Feb 16, 2009
21
US
Hi!
I'm using MS FoxPro for Windows 2.5a which was an upgrade from FoxPro for DOS 2.0. On November 18, 2014 we got the Distribution Kit for it. However, when I try to create an executable from my project created after the Kit was installed, it just starts up and closes never running the program that was set as 'Main'. What have I forgotten to do? From the research I've done I think I'm on the right track but the EXE just won't run the 'main' program. Help, Please!

Thanks,
MillsRS
 
In 1990 this was one of the most frequently asked questions on CompuServe's FoxForum.

You need a foundation read in your main program. Do you have one?
 
Oh, I realize I didn't say *how*.

Somewhere, do this:

Code:
Release glQuitting
Public glQuitting
glQuitting = .f.

At the point in your main program where you want the program to wait for user action, put this:

Code:
Read Valid glQuitting

In your menu's Exit option, put this:

Code:
glQuitting = .t.
Clear Read All

You can encapsulate all of this in your menu, actually (using the setup and cleanup snippets) but it tends to bury the stuff.

The foundation read can get a LOT more complicated, which is why we used to call it the DREADED foundation read, but this is the simplest form.
 
To danfreeman,

Many thanks for taking the time to answer my question. I will follow your advice tomorrow morning when I get back to work.

millsrs
 
To danfreeman & everyone,

I have tried coding in a 'Foundation' Read following the example code. Unfortunately, it made no difference. I even tried a variation on it to no avail. Many thanks to danfreeman for offering a suggestion that was more than worth trying!

My system is not menu-driven. A push-button handles the 'exit' from the system. Within FoxPro 2.5a for Windows it runs just fine. The building of the EXE doesn't even try to run the 'main' program. Any other ideas?

Please feel free to share.

Thanks!

millsrs
 
Have you used WAIT WINDOWs or something to see exactly how far it's getting?

Tamar
 
Follow Tamar's suggestion. We need more information at this point.

Within FoxPro 2.5a for Windows it runs just fine.

Do you have a command window when you run in the IDE? If so, YOUR PROGRAM IS NOT RUNNING.
 
Thank you Tamar and danfreeman. I will try the progress marking WAIT WINDOWs and I will also try closing the COMMAND window. Please let me know what questions you have to give you the additional information you would like. I will get back to you with it as quickly as I can.

millsrs
 
You misunderstood dan. It doesn't help to close the command window. The command window is automatically hidden, if a program runs and shows if it finishes. Started forms still are present and menus, etc. That's just because how awesome VFP can be tested inside the IDE without compiling to an EXE.

So, if the command window shows and your program is finished, closing the command window doesn't run your program again. The IDE in itself is keeping your menu, forms etc. in place, but that is not present, when you only run your compiled code. You never go into the mode "now, I'm ready, waiting for events", if you're through with generating a menu, opeing a database, starting a form and no code follows, the program is finishes and the runtime closes and quits everything, unless you're in the IDE (in Foxpro itself, if you don't know IDE stands for integrated development environment).

To see what dan means simply start a new project and just have this single PRG:
Code:
Public glQuitting
glQuitting = .f. 
ON KEY LABEL ALT+F3 glQuitting = .t.
Read Valid glQuitting

If you start that nothing happens, nothing is shown, but the command window will hide. You program is sitting on the READ and waiting for glQuitting to become .T.
How do you set it .T.? Press ALT+F3.

And now the command window comes back.

If you don't have this part of the code, your EXE runs, but finishes before you even have a first glimpse of things and could do a first key stroke or mouse click.

Bye, Olaf.
 
As Olaf says, you misunderstand.

The command window makes it look like your application is running but your application has actually ended.

You NEVER NEED TO CLOSE THE COMMAND WINDOW. It is not available when an application is running. If the command window is available then your application is not running. That's been a fundamental behavior of Foxpro since Foxpro/DOS 1.0.

The foundation read simply causes a wait state that holds you in your application. Nothing more. (Well, it CAN provide a lot more but at its core it's just a wait state that holds you in your application.)

(By the way, Olaf, setting glQuitting isn't enough to end a F'read. You also need something to exit the read, hence the CLEAR READ ALL.)
 
Thanks, Dan, for pointing out about the way READ VALID works. I'm glad this is simplified at least in higher versions, where the only READ we need is READ EVENTS.

Bye, Olaf.
 
Hello Tamar, Dan and Olaf!

Again, thank you all for your time and energy. Tamar advised to put in some WAIT WINDOWS to see how far the EXE gets. I've done so and not even the very first one (at the top of the program) appears. I've also put in the Foundation Read that was so strongly suggested. Again, no change. The EXE starts up and shows the Fox Splash screen and then exits never touching my code.

I did some additional research and learned that 2.5 for Windows creates 'compact' EXE's. So I found the support library file FOXW250A.esl and added it to the directory where the EXE is running. Even that made no difference.

Anyone have a suggestion?

millsrs
 
millsrs said:
The EXE starts up and shows the Fox Splash screen and then exits never touching my code.

I guess that maybe you should show us the code showing where it exits your EXE. We need the code that is running (splash screen) thru where it does not run but should run. That will bracket the exit point so we may be able find out exactly what is happening.

mmerlinn


Poor people do not hire employees. If you soak the rich, who are you going to work for?

"We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding. Answering questions for careless and sloppy thinkers is not rewarding." - Eric Raymond
 
It's odd that your application would show the Fox splash screen. How are you running the application?

At this point, I'd also like to see the main program.

Tamar
 
As always, thanks for your help! As you'll see, the screen builder started things and then I copied the code to a .PRG and expanded from there.
* *********************************************************
* *
* * 11/06/14 WELCOME.PRG 13:48:10
* *
* *********************************************************
* *
* * Alpha Products, Inc.
* *
* * Copyright (c) 2014 Alpha Products, Inc.
* * 351 Irving Drive
* * Oxnard, CA 93030
* *
* * Description:
* * This program was automatically generated by GENSCRN.
* *
* *********************************************************

WAIT WINDOW "Just starting Welcome.prg. Press a key..."
#REGION 0
REGIONAL m.currarea, m.talkstat, m.compstat
SET DEFAULT TO F:\GESTBOOK

IF SET("TALK") = "ON"
SET TALK OFF
m.talkstat = "ON"
ELSE
m.talkstat = "OFF"
ENDIF
m.compstat = SET("COMPATIBLE")
SET COMPATIBLE FOXPLUS

m.rborder = SET("READBORDER")
SET READBORDER ON
WAIT WINDOW "Just did SETs. Press a key..."

m.currarea = SELECT()
RELEASE lQuitting &&11/20/14RSM
PUBLIC lQuitting &&11/20/14RSM
lQuitting = .F. &&11/20/14RSM

* *********************************************************
* *
* * Windows Window definitions
* *
* *********************************************************
*

WAIT WINDOW "Environment has been setup. Press a key..."
IF NOT WEXIST("wwelcome") ;
OR UPPER(WTITLE("WWELCOME")) == "WWELCOME.PJX" ;
OR UPPER(WTITLE("WWELCOME")) == "WWELCOME.SCX" ;
OR UPPER(WTITLE("WWELCOME")) == "WWELCOME.MNX" ;
OR UPPER(WTITLE("WWELCOME")) == "WWELCOME.PRG" ;
OR UPPER(WTITLE("WWELCOME")) == "WWELCOME.FRX" ;
OR UPPER(WTITLE("WWELCOME")) == "WWELCOME.QPR"
DEFINE WINDOW wwelcome ;
AT 0.000, 0.000 ;
SIZE 38.846,150.800 ;
TITLE "Welcome to Alpha Products, Inc." ;
FONT "MS Sans Serif", 8 ;
FLOAT ;
NOCLOSE ;
MINIMIZE ;
SYSTEM
MOVE WINDOW wwelcome CENTER
ENDIF

WAIT WINDOW "Welcome window has been defined. Press a key..."

* *********************************************************
* *
* * WELCOME/Windows Screen Layout
* *
* *********************************************************
*

#REGION 1
IF WVISIBLE("wwelcome")
ACTIVATE WINDOW wwelcome SAME
ELSE
ACTIVATE WINDOW wwelcome NOSHOW
ENDIF
@ 1.846,54.200 SAY (LOCFILE("logo1.bmp","BMP|ICO", "Where is logo1?")) BITMAP ;
SIZE 4.692,39.400 ;
ISOMETRIC ;
STYLE "T"
@ 8.000,60.600 SAY "Welcome" ;
PICTURE "@I" ;
FONT "MS Sans Serif", 24 ;
STYLE "BT"
@ 11.308,28.800 SAY (LOCFILE("alphac~1.bmp","BMP|ICO", "Where is alphac~1?")) BITMAP ;
SIZE 14.846,90.000 ;
STYLE "T"
@ 28.000,42.000 SAY "Please Sign In Or Sign Out" ;
PICTURE "@I" ;
FONT "MS Sans Serif", 18 ;
STYLE "BT"
@ 32.500,40.200 GET cmdbutSignIn ;
PICTURE "@*HN Sign In" ;
SIZE 1.769,10.333,0.667 ;
DEFAULT 1 ;
FONT "MS Sans Serif", 8 ;
STYLE "B" ;
VALID _47b0tl32h()
@ 32.500,90.200 GET cmdbutSignOut ;
PICTURE "@*HN Sign Out" ;
SIZE 1.769,10.333,0.667 ;
DEFAULT 1 ;
FONT "MS Sans Serif", 8 ;
STYLE "B" ;
VALID _47b0tl32m()
@ 36.231,9.600 SAY "@Copyright Alpha Products, Inc., 2014"
@ 36.231,9.600 GET cmdbutExit ;
PICTURE "@*IHNT Exit" ;
SIZE 1.769,5.667,0.667 ;
DEFAULT 1 ;
FONT "MS Sans Serif", 8 ;
STYLE "B" ;
VALID _47b0tl32r()
@ 36.231,96.000 SAY "Quality Products For Quality Customers, Worldwide"
@ 36.231,96.000 GET cmdbutMaint ;
PICTURE "@*IHN Maintenance" ;
SIZE 1.769,12.667,0.667 ;
DEFAULT 1 ;
FONT "MS Sans Serif", 8 ;
STYLE "B" ;
VALID _47c0um43s()

IF NOT WVISIBLE("wwelcome")
ACTIVATE WINDOW wwelcome
ENDIF
WAIT WINDOW "Just before the master 'Read'. Press a key..."

*READ
READ VALID lQuitting &&11/20/14RSM
WAIT WINDOW "Just after the master 'Read'. Press a key..."
CLEAR READ ALL &11/20/14RSM

RELEASE WINDOW wwelcome
SELECT (m.currarea)


#REGION 0

SET READBORDER &rborder

IF m.talkstat = "ON"
SET TALK ON
ENDIF
IF m.compstat = "ON"
SET COMPATIBLE ON
ENDIF
*CLEAR &&11/20/14RSM
*QUIT &&11/20/14RSM

* *********************************************************
* *
* * _47B0TL32H cmdbutSignIn VALID
* *
* * Function Origin:
* *
* * From Platform: Windows
* * From Screen: WELCOME, Record Number: 5
* * Variable: cmdbutSignIn
* * Called By: VALID Clause
* * Object Type: Push Button
* * Snippet Number: 1
* *
* *********************************************************
*
FUNCTION _47b0tl32h && cmdbutSignIn VALID
#REGION 1
DO sign_in

* *********************************************************
* *
* * _47B0TL32M cmdbutSignOut VALID
* *
* * Function Origin:
* *
* * From Platform: Windows
* * From Screen: WELCOME, Record Number: 6
* * Variable: cmdbutSignOut
* * Called By: VALID Clause
* * Object Type: Push Button
* * Snippet Number: 2
* *
* *********************************************************
*
FUNCTION _47b0tl32m && cmdbutSignOut VALID
#REGION 1
DO sign_out

* *********************************************************
* *
* * _47B0TL32R cmdbutExit VALID
* *
* * Function Origin:
* *
* * From Platform: Windows
* * From Screen: WELCOME, Record Number: 7
* * Variable: cmdbutExit
* * Called By: VALID Clause
* * Object Type: Push Button
* * Snippet Number: 3
* *
* *********************************************************
*
FUNCTION _47b0tl32r && cmdbutExit VALID
#REGION 1
SET PATH TO
RELEASE WINDOW wwelcome
lQuitting = .T. &&11/20/14RSM
CLEAR READ ALL &&11/20/14RSM
CLEAR
*QUIT
* *********************************************************
* *
* * _47C0UM43S cmdbutMaint VALID
* *
* * Function Origin:
* *
* * From Platform: Windows
* * From Screen: WELCOME, Record Number: 8
* * Variable: cmdbutMaint
* * Called By: VALID Clause
* * Object Type: Push Button
* * Snippet Number: 4
* *
* *********************************************************
*
FUNCTION _47c0um43s && cmdbutMaint VALID
#REGION 1
DO wdbfmain
 
 http://files.engineering.com/getfile.aspx?folder=87d14a38-ff70-452d-965b-ce6a400f4ef9&file=WELCOME.PRG
OK, that is generated code for a screen. Is it set as main in your project? Actually, scratch that. It absolutely CANNOT be set as main since you don't see the very first wait window.

Most main programs look something like this:

Code:
glQuitting = .f.

* set up some stuff

Do mainmenu.mpr

* maybe...
Do yourscreen.prg

Read Valid glQuitting

BTW, it looks like here you've directly edited generated code. You do know this will be overwritten the next time you generate an EXE, right? NEVER EDIT GENERATED CODE.
 
I second dan:

danfreeman said:
NEVER EDIT GENERATED CODE.

When you are using GENSCRN to generate your screens, ALWAYS DO ALL OF YOUR EDITING FOR THE SCREEN WITHIN the various screen snippets (When, Valid, etc.)

If there is some standard routine that you want as a stand alone PRG, then put a call into one of the snippets to this stand alone PRG. You can edit the stand alone PRG to your hearts desire without interfering with the GENSCRN process.

For example if you want to use a standard validation routine you could put something like this in the appropriate VALID snippet:

Code:
V_NAME()

Be sure to check the 'expression' button in the snippet if you are ONLY calling a PRG.

If you have any other code in the snippet, then make sure that the 'expression' button is NOT checked and also make sure you have "=" before the PRG name, for example like "[tt]= V_NAME()[/tt]".

Then elsewhere create a PRG named [tt]V_NAME.PRG[/tt] for all of your standard code:

Code:
---> do something here

When the VALID clause is invoked within the generated screen by the program, the program will jump to [tt]V_NAME.PRG[/tt], do something, then return to the calling VALID clause.

This is a very simple example. There are many more complicated things that can be done in the various clauses, but until the program is at least usable, things should be kept as simple as possible.

mmerlinn


Poor people do not hire employees. If you soak the rich, who are you going to work for?

"We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding. Answering questions for careless and sloppy thinkers is not rewarding." - Eric Raymond
 
Many thanks to Dan and mmerlinn for submitting their advice. I plan to create a short 'main' program that will call the 'Welcome' screen. I'll keep you posted.
 
You don't *have* to have a main prg, but it's easier to manage.

I'm still concerned that you haven't set main to the right program.
 
Hi Dan, I have chosen to create a 'main' program named main.prg that contains the code you suggested and a call to the 'welcome' program. The code doing the same job in the 'welcome' program has been commented out. I set the new program as "Main" in the project. After creating an EXE and running it, there was still no change. The FoxPro splash screen comes up (not by my code) and then shuts down. Could the Distribution Kit be bad? On it's own the programs run as needed. Any other ideas? Thanks! I will also read up more on the VALID clause of the READ command so I understand it better. It just doesn't seem to be working as I think it should.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top