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

Curious... running code after THISFORM.RELEASE never noticed before

Status
Not open for further replies.

GriffMG

Programmer
Mar 4, 2002
6,333
FR
I was just debugging something and found that THISFORM.RELEASE does not VFP from running
valid code after that line. So the code below results in a messagebox appearing...

Code:
thisform.release
messagebox("HI")

Funny that I never spotted that before.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
Yes, it's curious, but it works this way. As we're at it, QUIT also doesn't quit VFP right away, it causes the SHUTDOWN event to occur and even if you don't have set ON SHUTDOWN to any routine all objects destroys are triggered. And for forms QueryUnload.

Back to RELEASE: you can only release the form object from memory after the call stack is cleared from any code of the form, so the current method will finish with all code after this line anyway.

So in this case, both messageboxes do display:
Code:
o = CreateObject("MyForm")
o.Show(1)

Define Class myForm as Form
   Add Object cmdClose as closebutton
   
   Procedure closetheform()
      Thisform.Release()
      MessageBox("Bye.")
   EndProc 
EndDefine 

Define Class closebutton as CommandButton 
   Procedure click()   
       Thisform.closetheform()
       MessageBox("Really, I said 'Bye'.")
   EndProc
EndDefine

Bye, Olaf.
 
That makes sense Olaf.

I will watch for this behaviour in future.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
The thing to remember is that it's still procedural code. It executes line after line.

There's nothing special about Thisform.Release() that will cancel the rest of the method. If you want to do *that* you issue RETURN.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top