VFP 9 - Can't delete Commandbutton without having the program crash

300 views Asked by At

I'm currently encountering a really evil error in VFP 9 SP2.

I created some forms and classes and my program runs just fine. Out of nothing the program is crashing and won't respond to anything, the only way to close it is via taskmanager.

I looked through all my code and found nothing but then I accidentally added a plain commandbutton to a container in my class (maybe it was just the right container ^^ ) and it worked fine!

But there's no place for this button and I wanted to get rid of it and everytime I tried to delete it, my program crashes again. I searched in my whole project with "go fish" multiple times - nothing!

Then I opened the .vct and found a line which seemed to had no reference and is never used in this class. I interprete this as an error from Foxpro, maybe a rest of code that hasn't been deleted the way it should. When I tried to delete it, my whole classlib has been destroyed.

If I try to set the .Visible-Property in my button to .f., the result will be the same - a crash.

So somehow I have to get rid of it. The class is too big to rewrite it.

I would be glad if you'd any suggestions on how to solve the problem.

4

There are 4 answers

0
Tamar E. Granor On

The kind of crash you describe generally indicates some kind of corruption either in a table or an index. Couple of things you might try:

1) Make a backup of the form, then USE it and PACK.

2) USE the form and copy it to a new file. Then rename the original and then the copy and see whether the new copy is better behaved.

Tamar

0
DRapp On

In addition to what Tamar mentioned, after the backup, if you use the form as a dbf such as

use MyForm.scx  [enter]
browse for baseclass = "commandbutton"

If you look at the memo fields, then open the memo field for "objName" and see if that is the one you added. If so, delete that one entry, then close the browse and pack the table. This should remove just the single element.

Then, after you close the MyForm.scx, for grins, force a fresh compile of the form via

COMPILE FORM MYFORM
0
Foxdancer On

in addition to the other posts: if you have a bunch of vcx/scx files (DBFs as well!) it might be helpful to narrow down where these files got corrupted because there might be several corrupted memo files or records.

Just create "copy to "-copies of all files AFTER issuing SET DELETED OFF which will create copies with identical record numbers.

Then loop through all records of each pair of tables and compare the memo fields which have readable (=non-binary) contents.

The field contents should differ only IF there is any memo corruption

close all
set deleted off
use tabel1_copy.scx
select 0
use table1.scx
SET RELATION to RECNO() INTO tabel1_copy
scan all 
  If  table1.field1 != table1_copy.field1
    ? "Houston we have a problem !"  
  ...
0
Caltor On

If all else fails create a new class and copy and paste the working bits into it.