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

releasing a form

Status
Not open for further replies.

megmogg

Programmer
Jul 14, 2005
76
GB

Hi all

searched the archives, but couldnt find an answer.

I remember seeing somewhere that when you issue a thisform.release, the code immediatley following it still gets executed. Is there something I need to put after a release to stop any further code executing.

An example is on the save of a button, if an error occurs updating a table, then I do the following.

Code:
If errorfound=.t.
   messagebox("Error")
   thisform.release
end if

(continue doing save routine)

Thanks



 

Thanks for the replies.

my routine is quite complicated, is there no other way?

I'm sure I saw somewhere you can do it.

could I issue a RETURN and the release ?



 
MegMogg,

could I issue a RETURN and the release ?

Well, you could. To adapt Marcia's code:

Code:
IF errorfound=.t.
   messagebox("Error")
   thisform.release
   return 
ENDIF
(continue doing save routine)

That would work, but I'm not sure what it would save you.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 

.... and, by the way. Why do want to close the form after you notified the user of the error? Wouldn't it make more sense from the user interface point of view if you left the form open so that the user could deal with the error?

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 

Thanks for the replies.

Mike: It was just a simple example to show what I wanted to achieve.

The reason I want to issue a RETURN is because the routine is quite long and I am trying to structure the code without lots of IF's and ENDIF's

By putting in the RETURN, it makes the code easier to read.

Thanks
 


yes, I agree.

However, the routine is already written and this easily solves the issue. But in the future......

 

Megmogg,

Although I agree with Geoff about not putting a RETURN in the middle of the method, in fact this is something I often do myself to simplify the code -- especially if I want to bail out as a result of some exceptional condition. Not good practice, but it can be convenient.

I take your point about your error message just being an example.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 


Thanks all for the replies.

My main issue is that the code for a save routine is a method in a form. If I was to structure it correctly, then the IF statements and indentation would be massive. Using the RETURN lets me structure the IF statements in smaller chunks, therefore less indentation.

The correct way, I persume, would be to put the save routine into a PRG. But the IDE interface I find arkward to manage for big projects. I would have to open the form and open the PRG and when there are hundreds of PRG's, it would be a pain to manage. The IDE would be better by being able to group PRG's to forms or some other grouping mechanism.....or am I missing the point?




 

Megmogg,

The correct way, I persume, would be to put the save routine into a PRG.

No. That would introduce an unwanted dependency, and prevent the form from being self-contained.

I suggest you stick to the solution you have chosen.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top