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!

please help me with: 'Cannot clear the object in use' error

Status
Not open for further replies.

teajean

Programmer
Oct 15, 2003
9
0
0
PH
Good day!

I have included the CLEAR ALL command in my ON SHUTDOWN procedure in order to successfully close & clean up my application. If for example, the last form I have executed is a modeless form, I don't have any trouble closing my application. However, if I have last executed a modal form, I always get the error message: 'Cannot clear the object in use'. I have read in vfp help that the cause of this error is that the method or event code for that object is currently running; and it recommends that I interrupt the running code or wait until it completes before clearing memory.

I'm not really knowledgeable in pure object-oriented programming in vfp, as I use the Form Designer in order to create my forms and I don't use wizards too. I have tried to understand and use the CREATEOBJECT function, and honestly, I still encounter the same problem I have stated. With this, I would very much appreciate any explanation as to what the error message I have stated above, means. Also, how do I interrupt the running code? If I'm right, I think I can't use the CANCEL command because I know that it will end the execution of my entire application.

Please do help me out, I've been trying to solve this problem for some time now. I would very much appreciate any kind of advice you can give me. Thank you very much.
 
HI

1. DOnt use CLEAR ALL.

2. I assume the following..

oForm = CREATEOBJECT(......)
oForm.Show()



Then in its release events.. exiting.. some where along.. you are trying to clear or remove oForm which is giving you error. You should not try to remove the variable oForm from within the form instatiated.

Instead.. after the
oForm.Show() above.. and the nature exit of the form..

oForm = .NULL.
or
RELEASE oForm

will take care of your concern.

:)

ramani :)
(Subramanian.G)
 
Teajean,

Here's a little program which I run from the command window whenever the program I am testing crashes, or if I need a quick way of cleaning up the development environment:

CLEAR ALL
RELEASE ALL
IF WEXIST("Standard")
SHOW WINDOW "Standard" && bring back main toolbar
ENDIF
CLEAR
SET SYSMENU TO DEFAULT
ON ERROR
ON SHUTDOWN
SET SAFETY ON
SET STATUS BAR ON
MODIFY PROJECT MyProjectName NOWAIT

Give it a try.

Mike


Mike Lewis
Edinburgh, Scotland
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top