Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
I need Better Database?
Message
De
30/07/2001 13:27:42
Walter Meester
HoogkarspelPays-Bas
 
 
À
23/07/2001 14:33:24
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00532220
Message ID:
00537316
Vues:
12
Cheryl,


>Would it be possible to see your code for handling the inconsistent record counter? I was just in the process of writing one for my error handling. Thanks in advance for your help.

Sorry for the late response (I had a week off).
Its a bit difficult to give you the code included in my framework as it contains code that is too interweaven with other functionality of the framework.

However, I've got some code from the old fp 2.x days which does in fact the same job. I've got part of the algorithm from something else, but I can't remember where I've got it from. Btw, don't mind the dutch text..


SET LIBRARY TO foxtools

SET SAFETY OFF
SET UDFPARMS TO VALUE

CREATE CURSOR x (naam C(20), DIR C(100))

DIMENSION afiles[1]
=ADIR (afiles,"data\*.dbf")
APPEND FROM ARRAY afiles
REPLACE DIR WITH "Data" FOR VAL(DIR)>0

l1err=.F.
SCAN
m.cfile=ALLTRIM(DIR)+"\"+ALLTRIM(naam)
? m.cFile

STORE FOPEN(m.cfile,2) TO m.nhandle
STORE FSEEK(m.nhandle,0,2) TO l1ndx_sz
=FSEEK(m.nhandle,0)

l1str=FREAD(m.nhandle,4)
l1ass=readx(4)
l1head=readx(2)
l1rec=readx(2)
l1actual=(l1ndx_sz-(l1head+1))/l1rec
l1actual=IIF(l1ndx_sz=l1head,0,l1actual)
IF l1actual<>l1ass
l1err=.T.
=Vraag("Het bestand "+m.cFile+"Bevat een fout. Deze wordt nu gerepareerd")
=FSEEK(m.nhandle,0)
l1str=FREAD(m.nhandle,4)
l1replace=RIGHT('00000000'+hex(l1actual),8)
l1tmp=''
FOR l1loop=1 TO 4
l1tmp=CHR(dec(SUBSTR(l1replace,l1loop*2-1,2)))+l1tmp
ENDFOR
=FWRITE(m.nhandle,l1tmp)
ENDIF
= FCLOSE(m.nhandle)
ENDSCAN
=Melding(IIF(l1err,'Er zijn fouten gevonden! Er dient ge-herindexeerd te worden',;
'Er zijn geen fouten gevonden'))
RETURN

*-

PROCEDURE vraag
PARAMETER m.cregel1
RETURN msgbox(m.cregel1,"",36)=6

*-

PROCEDURE Melding
PARAMETER m.cregel1
RETURN msgbox(m.cregel1,"",0)

*-

FUNCTION readx
PARAMETER l1len
l1str=FREAD(m.nhandle,l1len)
l1tmp=''
FOR l1loop=1 TO l1len
l1tmp=RIGHT('00'+hex(ASC(SUBSTR(l1str,l1loop,1))),2)+l1tmp
ENDFOR
l1value=dec(l1tmp)
RETURN l1value

FUNCTION hex
PARAMETERS l1int
PRIVATE l1loop,l1hex,l1str
l1str='0123456789ABCDEF'
l1hex=''
FOR l1loop=7 TO 0 STEP -1
l1part=INT(l1int/(16^l1loop))
l1hex=l1hex+SUBSTR(l1str,l1part+1,1)
l1int=l1int-l1part*(16^l1loop)
ENDFOR
DO WHILE LEFT(l1hex,1)='0'.and.len(l1hex)>1
l1hex=SUBSTR(l1hex,2)
ENDDO
RETURN l1hex

FUNCTION dec
PARAMETERS l1hex
PRIVATE l1loop,l1int,l1str,l1ctr
l1str='0123456789ABCDEF'
l1int=0
FOR l1loop=LEN(l1hex)-1 TO 0 STEP -1
l1int=l1int+(16^l1loop)*(AT(SUBSTR(l1hex,LEN(l1hex)-l1loop,1),l1str)-1)
ENDFOR
RETURN l1int


Walter,
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform