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

How can I clear the class or such codes lingering in VFP memory ?

Status
Not open for further replies.

ramani

Programmer
Mar 15, 2001
4,336
AE
Scenario..

1. Open a project
2. Open an existing class or form
Which uses the class already available in the project.
Now close the form or whatever opened.
3. Try to open the associated .VCX as if it is table
USE myVcx.VCX from Command window or in PRG code

a. File already in Use error comes up.

b. Try to select the area where it is open. I am unable
to identify the work area. CLOSE TABLES ALL, SET CLASSLIB
TO, RELEASE ... etc etc .. nothing provides an answer.

c. At this stage close the project and reopen it. Again
try to open the VCX.. no success. Somewhere the
associated thing is lingering.

d. From the command window CLEAR ALL gives a success. But
I cannot use 'CLEAR ALL', since the code is run from a
custom toolbar object which I have developed to help me
in custom development. I use 'Application.Projects'
objects collection to manipulate for my requirements. And
I need to open the project components as tables at times.
CLEAR ALL from command window will also clear the toolbar
object and I have to reinstate the toolbar again. SO I
achieve what I want by doing CLEAR ALL and starting the
toolbar everytime.

But it may be something silly I am missing and I want to
sort this out.

Thank you very much for anyone trying it out or providing
me the hint straightaway.

I believe, VFP is holding it in its internal session, but I am unable to access it. This is more like a bug and I want a workaround.

:)

ramani :)
(Subramanian.G)
 
ramani,

Just tried the steps you outlined above in VFP 7 and was unable to reproduce the behavior. Does this only happen in VFP 8 for you. Here are the steps I did...

Open project which contains a VCX

Open a form class in from the VCX in the project

Close form class down

Go to datasession window and open VCX as a table

...I tried this with set exclusive on and set exclusive off. I was still unable to get the file in use error. Am I missing something?



Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
I am running VFP 7 on Windows XP and I am unable to reproduce the error you are getting. If there is something wrong with the steps I outlined above please let me know. Is anyone else able to reproduce this?

Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
This is now puzzling me. !

I am able to produce the same behavious everytime and with different projects and in both VFP7 and VFP8.

Slighthaze, do you have some magic in your computer!.

Now one small doubt.. does the class or form you are opening is based on the VCX class you are opening ? (The other way I can also open the VCX .i.e a VCX class not used by the opened form.)

I dont know, if this adds to the owes..
my Forms is based on two classes, one form class and it also has an object based on another class, kept in the project. and both the VCX files cannot be opened by me as explained above.

:)

ramani :)
(Subramanian.G)
 
ramani,

Ahhhhhhh, have reproduced what you are seeing. When including second VCX with a form class and adding class object to it from the first VCX then I am unable to open the first VCX as table exclusively, can still open it shared, but exclusive gives me File In Use error. Will get back to you if I figure something out to fix it... very glad I am able to reproduce the problem. Is a bug I think.

Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
ramani,

TO REPRODUCE BUG:
[ol][li]Create form class named clsForm and save into One.vcx[/li]
[li]Create Textbox class named clsTextbox and save into two.vcx[/li]
[li]Add both VCX files to Project1.pjx[/li]
[li]Now open clsForm in design view and then close it[/li]
[li]Use "two.vcx" in 0 Exclusive[/li]
[li]Error "File is in use"[/li][/ol]
TO WORK AROUND BUG:
[ol][li]CLEAR CLASS clsTextbox[/li]
[li]Use "two.vcx" in 0 Exclusive[/li][/ol]


Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
Thanks Sighthaze for your efforts.

CLEAR ALL from command window will solve the issue. But I cannot do that from within my toolbar class instantiated in my development area. Also, when I use some of the tools, I need an exclusive use of the VCX as tables. That is the problem. I do a CLEAR ALL and restart my tool now. But doing it several times, is irritating and I want a way out. If a way out is there, I can imagine and find ways to use that as wrapper to add some convenient routines. Who knows, I could provide some tools/utils back to the users here for daily use, based on those wrapper.

:)

ramani :)
(Subramanian.G)
 
ramani

Above should read as follows:

TO REPRODUCE BUG:
[ol][li]Create form class named clsForm and save into One.vcx[/li]
[li]Create Textbox class named clsTextbox and save into two.vcx[/li]
[li]Create new Project1.pjx and add both VCX files to it[/li]
[li]Open clsForm from one.vcx in design view[/li]
[li]Add clsTextbox from two.vcx to opened clsForm[/li]
[li]Close clsForm and save changes[/li]
[li]Use "two.vcx" in 0 Exclusive[/li]
[li]Error "File is in use"[/li][/ol]
TO WORK AROUND BUG:
[ol][li]CLEAR CLASS clsTextbox[/li]
[li]Use "two.vcx" in 0 Exclusive[/li][/ol]


Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
ramani,

I am not using CLEAR ALL to fix, I am using CLEAR CLASS ClassName will it not work for you?

Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
No Slighthaze,

In my code, CLEAR CLASS does not clear it.
Various options I did,

1. CLOSE ALL
2. CLEAR CLASS myCalss
3. Close the project and open it by code
4. Pack the project by code

Checked all work areas and closed all possible, by
CLOSE TABLES ALL
CLOSE DATABASES ALL

Selected the work area using the same macro which finds the 'file is in use' error.. and giving a USE command to close it.
USE IN (myClass) where possibly to my knowledge the Class might have been opened.. (obviously I am not achieveing that).

and some such options. No luck to me.

:)

ramani :)
(Subramanian.G)
 
my Forms is based on two classes, one form class and it also has an object based on another class

When you use CLEAR CLASS are you using it to clear the class object that is based on another class? Say other class object on your form is clsMyClass (based on clsMyBase)...are you using CLEAR CLASS clsMyClass?

Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
I do not mean to continue to belabor the point with you ramani, I only wish to help. CLEAR ALL works for you because it is clearing a class out of memory, so trick is to find the classname of that class and clear it.

Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
Hi slighthaze,

You are not prolonging the thread. In fact I thank you, you are trying to help me. And so long I dont eat your time and patience or of others here, it is OK.

You know what happens when people of my level see some problem. I will come out only when I cant solve after prolonged efforts. Most of the points you or others specify might have been already done by me.

Yet, it could be SOME SIMPLE LINE that is overlooked or eluding me and SOME ONE can drive that into my skull. So it will be painful to see and get the final result. And no simple code of any one can be ignored and taken as simple.

So keep it in one corner of your brain cells as I do. Some point of time, a flash could give some light and this can be solved. Ignore it for some time, that you have put in so much efforts for me.

One thing I have not done and I am going to do now, is that I first want to loop thru all VCX and attempt to mock release/clear, before starting the loop to process mine. This idea flashed only with your last thread. Hope I get some result. Now I will go and test and see what happens. I will report only if I succeed in it so that I dont influence you to work more on this now.

Big thanks Slighthaze for your time. Hope I succeed and put a shining star to you. :)

ramani :)
(Subramanian.G)
 
Ramani and SlightHaze

I remember encountering this situation why working on developing faq184-2409, where I was trying to subclass all the Wizard classes of VFP and kept coming up with the "file in use" error. You will notice that I had to use "SHARED" in my code to avoid that.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike,
I need the opening EXCLUSIVE. May be I missed to mention in my original thread, but explained it somewhere along.

Did you open exclusive any time in those circumstances ?. If yes, you have an answer for me.

Slighthaze, Just feedback on my last thread to you.. NO LUCK.

:)


ramani :)
(Subramanian.G)
 
Ramani

Have you tried
SET CLASSLIB TO ?

Or I noticed that this also works:
Code:
USE c:\assurance\data\analysis.dbf EXCL IN 0
USE c:\assurance\data\analysis.dbf SHARED AGAIN IN 0 && No error


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Yes mike, I tried those.

What is creating the error, is that the VCX is not open in reality, but the VFP is holding the cache somewhere and so, for example, I need to open it again EXCL, it will say altready in USE error.

SET CLASSLIB TO or CLEAR CLASS myClass should do it. But it seems a bug.

Only CLEAR ALL is removing it, which I cannot use from within toolbar.

:-(

ramani :)
(Subramanian.G)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top