Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help with MAIN program code
Message
From
10/10/2001 13:56:24
Peter Brama
West Pointe Enterprises
Detroit, Michigan, United States
 
 
To
10/10/2001 13:39:10
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00566287
Message ID:
00566545
Views:
13
Dragon,

What started this all was the PRG like this:
set talk off
set deleted on
set bell off
set sysmenu off
set multilocks on
set exclusive off
on shutdown quit

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

use mysystfile
if empty(mysystfile.fmyfield) then
  if reccount()=0 then
    append blank
  endif  
  do form mysystform to vAbort
  if vAbort=.T. then
    clear events
    quit
  endif  
endif    

do form myinitialform
read events
When this runs, if the MYSYSTFILE is basically new, it adds a record then goes to the mysystemform which is a modal form. If the user cancels the form or forgets to fill in the data field the form returns a .F. and I thought I needed a CLEAR EVENTS and the QUIT to abort out of the app.

With a WAIT WINDOW placed right before the clear events in the abort if/endif, I could tell I was getting the abort but then then it fell through the remainder of the if/endifs and fired the MYINITALFORM which generated an error.

So the answer to your first question, did it work, nope.


I tried putting it, I believe (I have moved this around so many times in the last two days) in the LOAD of the MYINITIALFORM but I believe I was running into some problems with that as well. I think that is why I decided to try to understand the MAIN.PRG coding and the "why"s for how it works. I think I am definately losing it when it comes to the READ EVENTS/CLEAR EVENTS stuff. I use to program straight 'C' years back and understand program flow, but the EVENTS stuff is confusing me as is basically OOP to some degree I guess.

Do most people have just simple MAIN.PRG that set some screens stuff and a few variables then the last two lines of the main are DO SOMEFORM and READ EVENTS with nothing after that?

>>I am having more difficulty with "stopping" the app. As I mentioned, I do have the SYSTEM form modal and returning a value. I do have the PRG trapping the return and attempting to"
>>
>>
>>if vAbort=.T. then
>>  clear event
>>  quit
>>endif
>>
>
>You didn't say whether this worked or not.
>
>>I also call the SYSTEM form from MYINITIALFORM when a user wants to changes some system settings. It to traps the vAbort with:
>>
>>
>>if vAbort=.T. then
>>  thisform.release
>
>Insert a RETURN here.
>
>>endif
>>
>>
>>The problem on this call is that the form is NOT releasing.. it is hitting that line and processing through it continuing on with the next line after the ENDIF, thus generating an error when it tries to do something with the missing system information. I know it is hitting the thisform.release because I have put a WAIT WINDOW in the if/endif loop to watch for it.
>
>In addition to what JCF told you, why don't you move the checking of the records in the myinitialform into its .load? You can even create the table there if it's not found, return .f. from the .load if something's awfully wrong etc. You can set thisform.OK to .t. or .f., depending on any tests you may run there, and Return not Thisform.OK from its unload. You may decide to show the form or not etc all from within the form.
>
>Thus you encapsulate the whole logic into that form, and have only two possible outcomes: your system table is OK, or the form returns .f.
>
>Your main.prg logic may be thus be simplified to
>
do form myinitialform to vAbort
>if vAbort
>   quit
>endif
>do form mymainform
Peter Brama
West Pointe Enterprises

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

Click here to load this message in the networking platform