fdbozzo / foxbin2prg

Visual FoxPro 9 Binary to Text and Text to Binary converter. Replacement for SCCText(X) and TwoFox that is bi-directional (Text is editable)
https://vfpx.codeplex.com/wikipage?title=FoxBin2Prg
MIT License
59 stars 35 forks source link

After vc2 convert back to vcx class is corrupted no errors reported #78

Closed bjornhoeksel closed 2 years ago

bjornhoeksel commented 2 years ago

ℹ Computer information

📝 Provide detailed reproduction steps (if any)

After vc2 convert back to vcx class is corrupted no errors reported

problem caused by code:

Procedure ignoreCorruptedObjects(lcCursor)

suggested fix:

Procedure ignoreCorruptedObjects(lcCursor)

✔️ Expected result

a valid vcx with all classes

❌ Actual result

corrupt vcx missing classes. this is reported bij vfp when open in a class browser

📷 Screenshots

lscheffler commented 2 years ago

Please post an example (VCX, VCT, VC2). If not possible in open, just let me know your contact info.

bjornhoeksel commented 2 years ago

Please post an example (VCX, VCT, VC2). If not possible in open, just let me know your contact info.

After converting vc2 back to vcx the vcx is missing classes and gives errors when opening in class browser ac1_dlg.VC2.txt

lscheffler commented 2 years ago

Analysing

Running FoxBin2Prg against your VC2 never reached ignoreCorruptedObjects

Analysing your vc2 I found the following problem(s):

bjornhoeksel commented 2 years ago

IF (NOT EMPTY(lcParentObjName))
Skip Delete Rest While Getwordnum(Lower(Parent) + '.', 1, '.') == lcParentObjName Skip -1 ENDIF

No problem is in de code below.

Scan For PLATFORM = "WINDOWS" And Empty(Parent) And Empty(RESERVED1) lcParentObjName = Lower(OBJNAME) Delete Skip Delete Rest While Getwordnum(Lower(Parent) + '.', 1, '.') == lcParentObjName Skip -1 Endscan

when I run it with new exe build with code with extra if check. then convert works fine. and all my other vcx are converting good as well without this adjustment some of our vcx end corrupted or missing classes. maybe run the code with debug with the vc2 I send before. Its difficult to send a better example. Maybe is the problem in generating vc2 I will try to send the vcx file. I think you can reproduce the problem then

Code that works: Scan For PLATFORM = "WINDOWS" And Empty(Parent) And Empty(RESERVED1) lcParentObjName = Lower(OBJNAME) Delete IF (NOT EMPTY(lcParentObjName)) Skip Delete Rest While Getwordnum(Lower(Parent) + '.', 1, '.') == lcParentObjName Skip -1 ac1_dlg.vcx.zip

ENDIF   

Endscan

lscheffler commented 2 years ago

Ok, the problem is in converting the vcx to vc2, not the other way around. Please check the vc2 file for class ac1_msg_client, it should be there but isn't. We agree that the class is in the vcx. The vcx seems corrupted.
Checking the vcx using USE and BROWSE, I can see there is an oddness in class ac1_msg_client. Go to Records 95 to 98

The records 95,96 are not defined, as they should be. (see the class above, any class is the record following not so unique *UniqueID=="RESERVED' to (including) the next occurrence of this ID, the order of records defines ZOrder) Deleting those two records in the vcx will create the ac1_msg_client** in the vc2, and the result of the recreation will be fine.


So maybe the change you mention removes just those two lines while creating the vc2. I have no time to follow this yet, I will check later.

bjornhoeksel commented 2 years ago

Ok, the problem is in converting the vcx to vc2, not the other way around. Please check the vc2 file for class ac1_msg_client, it should be there but isn't. We agree that the class is in the vcx. The vcx seems corrupted. Checking the vcx using USE and BROWSE, I can see there is an oddness in class ac1_msg_client. Go to Records 95 to 98

The records 95,96 are not defined, as they should be. (see the class above, any class is the record following not so unique _UniqueID=="RESERVED'_* to (including) the next occurrence of this ID, the order of records defines ZOrder) Deleting those two records in the vcx will create the ac1_msg_client in the vc2, and the result of the recreation will be fine.

So maybe the change you mention removes just those two lines while creating the vc2. I have no time to follow this yet, I will check later.

Hi We have some vcx files that give problems with this code when lcParentObjName = "" and code seems to deletes random reccords in that situation. The vcx if i complile it with compile classlib i have no errors. In the comment above the problem code is the following mentioned

Procedure ignoreCorruptedObjects(lcCursor)

But for us this code creates problems and missing classes when lcParentObjName is empty. When i fix it by not keep delting if lcParentObjName is empty all works ok.

lscheffler commented 2 years ago

@bjornhoeksel, I understand the problem. In general, VFP is sometimes odd what works and what not. FoxBin2PRG parses the vcx as a table and assumes some things. For what ever reason, some of your VCX's are not in perfect order (do you use something non build in to work with classes?).
FoxBin2PRG just fails (without your change) to find those classes in the vcx and skip to the next class, so the class is missing in the vc2. A class not in the vc2 can not be recreated, and then you got problems.
If your fix is working, it will generate uncorrupted vcx files and all is good after first recreate. So in this sense it will repair the vcx.

I just need to think through your fix, and I need time to push it anyway. It will be done this weekend.