Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help with MAIN program code
Message
From
10/10/2001 00:04:35
Peter Brama
West Pointe Enterprises
Detroit, Michigan, United States
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Help with MAIN program code
Miscellaneous
Thread ID:
00566287
Message ID:
00566287
Views:
50
VFP 101 at it's best... one of those things that I have ALWAYS done the same way and now I think I might need to change somethings and not sure if or how it can be done.

Under the CODE tab of the Project Manager, I have a "main" program that is set as the main and as I understand it, it is the first thing run in the executable. That said, my main programs always were very few lines and looked basically like this.


---------------------myapp.prg------------------------------
set talk off
set deleted on
set bell off
set sysmenu off
set multilocks on
set exclusive off

clear
_screen.windowstate=2
_screen.caption="My Program v1.0, Copyright 2001 West Pointe Enterprises"
_screen.backcolor=rgb(58,110,165)
_screen.minbutton=.F.
_screen.maxbutton=.F.


do form myinitialform
read events
----------------------------------------------------------------------
Pretty straight forward I think. Now here is where things get interesting...

My current applicaton has a SYSTEM file that has some field definitions that I need for most of my forms (to make it very portable). When the program is run for the very first time, that file (will call it MYSYST) does not have any rows in it, completely empty. When this happens, I need to call a different form, one that is linked to the MYSYST file through the DE. What I thought I needed was:

use mysyst
if reccount()=0 then
append blank
do form mysyst
endif


This needs to happen BEFORE myinitialform above is called because without information in this file... the form will crash badly (missing data for the recsource & controlsources of a grid!!)

As I looked at this, from basic programming days, it would go immediately before the DO FORM MYINTIALFORM call. But here is A) where I am getting confused and B) doesn't seem to work.

a) When does this fire in relationship to the MYINTIALFORM and better yet the READ EVENTS?

b) I put it here... the form MYSYSTFORM displayed but when I tried to work with the form, I kept getting unreferenced errors for each field and further testing showed that the appendblank apparently didn't happen correctly???


Now to add insult to injury, if the user cancels out of the MYSYSTFORM without filling in certain fields, I can't have the remainder of the program run at all, it again will crash. That in mind, I need some sort of returning error checking and I set the MYSYSTFORM up to be MODAL and return a .T. in the UNLOAD if the form is cancelled. That didn't seem to work either. I modified my main program to read:

use mysyst
if reccount()=0 then
append blank
do form mysyst to vAbort
endif
if vAbort<>.T. then
do form myinitialform
endif

Again, that might be wrong as well.



This has been a problem most of the day. I originally put this in the MYINITIALFORM.LOAD but had problem with the aborting and grid references again. I really think it needs to be outside MYINITIALFORM but not sure quite where or how. In some other apps I have written, they open to a form that is a system menu. That makes things easier but this app is basically one form and doesn't need a menu for one single item.


Suggestions?
Peter Brama
West Pointe Enterprises

VFP is getting easier but STILL alot to learn!!
Next
Reply
Map
View

Click here to load this message in the networking platform