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!

Broken VCX? What did I do wrong?

Status
Not open for further replies.

steve4king

IS-IT--Management
Feb 6, 2007
154
US
I just created a new class through the fox UI. Spent the last six hours or so on this.

The class was functioning just fine, but the project seemed to have cached an old version of the class and only called the new one if it was dragged onto a form.
The class exists in two directories: MyDocs and my project's home directory.
I copied the newer one over the older one in mydocs without effect.
I removed the class from the project.. still no effect, it still ran the old version.
So, I closed fox and reopened.

Now when I re-add the class, my project can't find it at all. It is not modifiable, and when added to the project, I don't see it in a hierarchy: can't be expanded. (default is just redundant class under it's own name since this class is by itself in the vcx.) No error message, but I can't seem to do anything with the class now.

What did I do to break it?
How can I recover it?

Thanks.

 
You say you copied the newer one over the older one. Did you copy both files, that is, the VCX and the VCT. These files together constitute the class library, and it is important that you keep them together all the time.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Assuming you did correctly copy both the VCX and the VCT:

Can you open the VCX in the Class Designer?

Launch the Class Designer from the Tools menu, then click the Open button and navigate to the VCX. This will at least tell you if the properties and methods are still intact. If so, we can tell you how to recover the code.

If that doesn't get anywhere, try opening the VCX as a table (with USE MyClassLib.VCX). Then browse it. Study the Objname, Properties and Methods fields. Can you see anything recognisable in them?

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
I think Mike means Class Browser, not Class Designer, from the Tools menu.
 
Dan said:
I think Mike means Class Browser, not Class Designer, from the Tools menu.

That is correct. I often make these deliberate mistakes. It's my way of making sure you're all paying attention.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
I did copy both.. if I open the VCX in the class designer it doesn't display any information. Regardless whether I open the one in mydocs or myproj.

I can browse it and the properties and methods are exactly as I'd expect to see them.
 
All the cool kids are saying "designer" though so, I can't fault you for that.
 
Actually, if I click modify and reselect the file, I get an error box that says,
"class name is invalid"
Browser: classbrowser1
object: classbrowser1
error: 1949
method: modifyclass
 
Hmm. It very much looks like the class library is corrupted.

But before writing it off, what about if you open it in the Class Browser, and then click the "View source code" button (the fourth button to the right of the combo box in the toolbar)?

If that doesn't work, the only thing I can suggest is that you re-create the class from scratch. But don't write all the code again. Instead, browse the old VCX file (like you did before), and copy and paste the code out of the Method fields. You can also use the Properties field to see what your previous property settings were.

Or maybe you want to hang fire for a bit in case anyone has a better suggestion.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Thanks Mike,
View source code displays a blank window. Also, the library icon(stack of books) is greyed out.

So if it's corrupted.. is there any trick where I can move the contents of the library into a new blank one?
I supposed I can copy my methods one at a time, but that's really no fun.


 
View source code displays a blank window. Also, the library icon(stack of books) is greyed out.

Are you saying that the left-hand panel (in the Class Browser) is blank? You would normally expect to see a list of the classes there. In particular, you would see the name and path of the VCX file at the top, with the name of each class within the VCX below. Are you seeing that?

Also, what happens if you click on the View Class Code button?

is there any trick where I can move the contents of the library into a new blank one? I supposed I can copy my methods one at a time, but that's really no fun

That's what I was suggesting when I said to browse the VCX file, and copy the contents of each of the Method fields to a new class. If all else fails, that would at least save you the effort of re-writing all the code. But it would be very much a last resort.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Are you saying that the left-hand panel (in the Class Browser) is blank? You would normally expect to see a list of the classes there. In particular, you would see the name and path of the VCX file at the top, with the name of each class within the VCX below. Are you seeing that?
Exactly, no list of classes. All I see is a greyed out icon and the name of the vcx file. Clicking view class code just opened a blank window.

I ended up just opening the vct in a text editor to copy out the methods and view the list of properties to re-create the class. (a little bit easier than browsing the vcx)
I don't know how it became corrupted, but I appreciate the help.

Thanks!
 
Steve, sorry I couldn't suggest a simpler solution, but I'm glad you've got past it.

You're not alone in having this sort of problem. I've got in the habit of taking a quick backup a couple of times per day when I'm working on a particularly large form or class. I just do a quick copy and paste within the folder window, then delete the copy after I've done my normal end-of-day backup. VCXs and SCXs are particularly fragile, as you unfortunately found.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top