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

more questions on form flow control ---- ARGHHHH!

Status
Not open for further replies.

FAC17

Programmer
Jan 24, 2002
26
0
0
US
Forever humble here...

I read (and appreciated) your responses. I now understand that I only need to read and clear events ONCE in a program. Okay - got that.

I even went and read all the stuff I could find in the help files...

But I haven't been ablt to answer my question.

Here is what I have

main calling prg looks like this:

goagain = .t.
do while goagain

do form main1 with goagain
read events
endif


Form main1 is displayed properly

Data is entered into form and a command button clicked. In the Click Event of the command button is some code that checks the data (maybe shouldn't be here but it is until you tell me a better place). An error condition arises and the messagebox is displayed just fine.

After the control returns from the messagebox I want to stop execution of the code in that click event and return to the calling prg, loop around and call the main1 form again but it continues execution of the code in the click event. I have tried ThisForm.release() and a bunch of other dumb stuff that hasn't worked.

Can you pleas set me back on the path again. This is soooo frustrating!!!

 
HI

REPLACE YOUR CODE....

goagain = .t.
do while goagain

do form main1 with goagain
read events
endif

WITH...
do form main1
read events

** I dont find a reason for passing a parameter into main1
***************************************

Now in the main1 form.. you have a click event..
In the click event you are checking for the error condition for some of your text fields or other control fields..
The way to check is..

ClickEvent of the buttom in Main1 form..
****************************************
LOCAL inError
inError = .f.
IF EMPTY(ThisForm.Text1.Value)
=MESSAGEBOX("Name shall not be left blank.", ;
0+16,"Data Entry Error")
ThisForm.text1.SetFocus
inError = .t.
RETURN
ENDIF
**
IF ThisForm.Text2.Value # "XYZ" && silly error condition
=MESSAGEBOX("Family Name shall be only XYZ.", ;
0+16,"Data Entry Error")
ThisForm.text2.SetFocus
inError = .t.
RETURN
ENDIF
**
IF ! inError
DO WHATEVER TO SAVE THE RECORD
ENDIF

This will cycle thru the form once again.. so long the data is not correct. Otherwaise you can click on cancel.. do the cancellation and exit the form thru an exit button click event.

Hope this helps you :) ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
When you jump to another event from within say a click event, execution does not stop in the click event. Microsoft told me to use the form of :

Done = MESSAGEBOX(YOURSTUFF)

to force the method to stop and wait on a return. Done is just a dummy variable to trick the method into waiting on it to be populated prior to continuing. Returning from the messagebox puts .t. or .f. (we don't care which) into Done, and then lets the click event continue on its way. Maybe this will help you.
 
Well, actually an integer is put into the DONE variable, and the assignment isn't necessary, ie:

MessageBox("Your message Here")

works fine.

Now, as for the code design, Ramani is correct, you probably don't want your READ EVENTS in a DO WHILE loop...

Think of it this way:
READ EVENTS is your event processor, as long as VFP is sitting on READ EVENTS, your program is running. Use menues, buttons on a main form and buttons on a toolbar to launch the other forms in your program.

Here's another overview:
In your main program (say, MAIN.PRG):
Code:
LOCAL Splash
DO FORM SplashScreen NAME Splash && Non-modal form
* Setup your menues
* Setup your toolbars
* Setup other junk for this program
Splash.Release
DO FORM Main1  
READ EVENTS
* Take apart other junk from this program
* Delete any temp files
* Restore Debug (system) menu

Now, the menues and toolbars (and maybe buttons on Main1) launch all the other forms in your app. Main1 COULD be a central location with a bunch of buttons and stay up all the time, or be a login screen, or whatever.

Have a choice on your menu "Exit" that issues "CLEAR EVENTS" (or a button on Main1, or in Main1's UnLoad event... in which case Main1 is to be open as long as your program is running)

If you have more related questions, feel free to respond on this post instead of starting a new thread on each variation.
 
To prevent the rest of your code in the CLICK() event from executing, just issue a RETURN:
[tt]
IF ErrorOccurred
MessageBox("Uh oh!")
THISFORM.Release()
RETURN
ENDIF
...
(the rest of your code if no error)
[/tt]
Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top