Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
FPD25 Manually correct 30 bytes of a corrupted Table hea
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00936241
Message ID:
00936429
Views:
118
This message has been marked as a message which has helped to the initial question of the thread.
>Hi Rich
>
>Thanks for both version of your code, the VFP code I think will not help as the extra bytes are just after the header and before the data starts. Maybe I can adapt the FPD version of your code for the same.

Maybe this modification to Tore's program will help
lcFile=yourfile
lcTekst=filetostr(lcFile)
lnStartBad = position of first byte to be removed
lcTekst = STUFF(lcTekst,lnStartbad,30,"")
strtofile(lcFile,left(lcTekst,lnLength-30))
>
>In the meantime I had downloaded a util Hex Editor and it had allowed me to remove the 30 or so bytes just like you would in a text file, to an extent this worked, but there are also overwritten and extra bytes per record, that is one hell of a job, so close yet so far.
>
>Any advise.

If there is a pattern to the positioning of the extra bytes per record you can modify the following
FUNCTION glopt
clear
lcTekst="aaaaaaaaaabbbd1111111111rrrd2222222222rrrd3333333333rrrd4444444444rrr"  && filetostr(lcFile)
&& a = header bytes
&& b = bad header bytes to be removed
&& d = record delete byte
&& 1,2,3,4   data bytes for the record
&& r = extra bytes to be removed from data records


lnDataByte = 14
lnRecLen = 14   && Record Length    delete byte 10 data bytes 3 bytes to remove
lnRecCount = 4  && Record Count
lnDelBytes = 3  &&Number of bytes per record to delete
FOR I = lnRecCount TO 1 STEP -1
  lnStartByte = lnDataByte + lnReclen*(I-1) + (lnReclen-lnDelbytes)
  lcTekst = STUFF(lcTekst,lnStartByte,lnDelBytes,"")
ENDFOR
lnStartBad = 11 && position of first byte to be removed
lnHeaderBad = 3 && Number of bytes to remove from header
lcTekst = STUFF(lcTekst,lnStartBad,lnHeaderBad,"")  
return lcTekst
I'm assuming here that the header record has the correct record count, record length, etc. and that the actual file doesn't reflect what the header shows. If not, at least I had some fun writing it.

Best of luck
>
>Thanks for your help.
>
>>I'll also repeat Tore's warning..........Make backups first!!!
>
>Yes I will take care. Clients dont but we generally do <g>.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform