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

Unwanted classes

Status
Not open for further replies.

Polly66

Programmer
Nov 3, 2001
42
AU
Hello everyone,

Is there a way to find (easily) what class libraries are included in any specific project. I seem to have a rather bloated application due in part to my inexperience with VFP9. I have searched through forms and controls for included classes that shouldn't be required but cannot seem to eliminate some, which do not appear to be required anywhere, from coming back no matter how many times I remove them.

Thanks if anyone can help.

Bill
 

Bill,

One way to do this would be to click on the Build button in the project manager, and select the Rebuild Project option. VFP will then go through the project, adding every VCX or PRG that contains the definition of the classes you are using.

That won't tell you which objects are based on those classes, however.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hi Mike,

Thanks again for your advice, but I have already removed all of the classes from the project that I don't want, only to see them reappear when I re-build. I thought there might be some way to determine which forms/controls used these classes, mostly wizards BTW. I have inspected the properties of each form/control and nothing that I don't want included appears to be there. I guess this will teach me a lesson for the future should there be a total re-make. Thank you for your time.

Kind regards.

Bill
 
If the project manager pulls a class library into the project during the build, then SOMETHING in the project is using it.

You mention wizards. Anything built by the wizards will inherit from the wizards' classes, so those classes will all get dragged into the project.

I wouldn't worry about it if I were you.
 
Hi Danfreeman,

Thank you for your interest in my problem. I realise that there are obviously some things that either call these classes or use them. I have inspected the properties of every form and control, and I cannot find where these calls are being made. I guess one aspect of my concern, which shows my age, is that I always worry about the size of the 'exe' file. Another part of me finds it difficult to rest when I do not know why something is occuring. I am extremely appreciative of the time you, and others on this forum have taken in responding to my concerns over the past few months.

Bill
 

Bill,

I have already removed all of the classes from the project that I don't want, only to see them reappear when I re-build

That was exactly what I intended. My point was that, by doing a re-build, you would discover all the libraries that were being referenced by your forms and programs. But you're right that that wouldn't help you determine where they are being referenced.

The only solution I can think of is to use Code References to search for the library names. That should tell you which objects have the relevant names in their ClassLibrary properties.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Bill,

How about this:

Write a program that loops through all the SCXs and VCXs in your project. For each one found, it would open the file as a table, then search its Classloc field for the names of the VCXs that contain the unwanted classes. It would then display the contents of the ObjName fields. That would tell you which objects are based on classes in the libraries in question.

If that sounds like too much trouble, consider Rick Schummer's HackCX tool (see This can give you the same result as the above program, except that you would do it interactively, by searching for each of the unwanted class libs in turn.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Bill
danfreeman said:
I wouldn't worry about it if I were you.
I would second that opinion.


There a couple of other things you can to to reduce the size of the .exe prior to distribution.

VFP Menu > Project > Clean Up Project

VFP Menu > Project > Project Info and select Project tab.

Ensure 'Debug info' is unchecked

Compile and compare the difference

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommander[sup]tm[/sup].net
PDFcommander[sup]tm[/sup].com
 
Hi Mike and Chris,

Thank you both for your valuable suggestions. Yours in particular Mike will assist with future documentation. I agree that the size of the 'exe' file probably dosen't matter, but it just bugs me that I don't know. I will find the answer to this problem, and I know that it will be some silly little thing that I missed everytime I checked before. Thank you to all who responded.

Bill
 
Hi Polly,

you said you've inspected the properties of each form and control. It's the .class and .classlibrary property which shows you which class of which classlib a form or control is. If classlibrary is empty this means it's some native class. Otherwise it's code like createobject, addobject or newobject, which tells you names of classes and classlibs used. And finally there are SET CLASSLIB and SET PROCEDURE command, normally within the main prg, that define which classlibs and prgs (which may include classes defined with DEFINE CLASS) are used.

Simply removing classlibs you "don't want" can even harm the project, if you remove something, which is not obviously needed and may miss at runtime only if a certain subform of some seldom used menu item is used, or whatever.

Newobject can instantiate any class on any file, even ones not contained in projects. But when compiling as EXE, if those files are excluded, the EXE may work on your computer, but not on others, as files are missing.

So if it ain't broke, don't "fix" it.

Bye, Olaf.
 

I have to say that I disagree. This isn't just a matter of saving space in the EXE. If the app contains references to classes, and you don't know where those references are, you could be storing up trouble.

For a start, are you completely certain that the classes in question are really unnecessary? Suppose one day you do a bit of spring cleaning, and end up deleting the class libraries. Can you be sure your application will still run? Perhaps, deep down in the app, there is an object based on one of the problem classes. If the class is no longer available, the object won't instantiate.

Or what if you, or a colleague, or a future developer maintaining the app, one day come across the classes, and decide to modify them. Can you be sure there won't be side effects?

Basically, I think it's dangerous to have anything at all in a project that you don't understand - let alone having dependencies on components that you can't even find. It's not enough to say, "Well, the app is working, so why worry about it."

My advice would be to use one the techniques suggested above to root out all the unknown references, and then fix them.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hi Olaf,

Yes you are right. I am having a problem with the application not working on some computers. Even in my own environent. I copied everything from my application/development PC directory onto a CD, then copied everything to a laptop, and still met the file not found/ does not exist etc scenario. Man have I ever learned my lesson. I now have my own class library, and I use nothing that isn't in there. Thank you very much for your time in reponding to my problem.

Bill/(Polly, who is my beautiful faithful Shetland Sheepdog).

 
Hi Mike,

I think we don't disagree. If a class is within a project it's normally needed. So you should only delet it, if you really know what it is and you know you don't need it. Thats why I set fix in quotation marks...

If you delete something and it doesn't come back with build it was not needed at compile time, but it could still be needed at runtime.

The statement "if it works, don't fix it" is correct for projects one didn't yet touched and didn't yet tried to minimize only.

Bye, Olaf.
 
Bill/Polly66 said:
I always worry about the size of the 'exe' file.
Something that I do when I notice that an EXE file is rather large is USE each of my VCX files and PACK them to remove deleted records. Perhaps "Clean Up Project" suggested by ChrisRChamberlain does that automatically.

Teresa
 
Thank you Mike Yearwood and Teresa for your valuable comments, and thanks again to all who responded to my recent requests for assistance. Prior to starting this particular project I had not done any development for a while, and as this will be my "swan song" I will sign off and out.

My kindest regards to all who have helped me through my difficulties.

Bill Shepherd.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top