udfFileCrc32 (sFilename)
;------------------------------------------------------------------------------------------------------------------------------------------
If ItemLocate("udffilecrc",IntControl(77,103,0,0,0),@TAB) Then Goto skip_udffilecrc
#DefineFunction udfFileCrc (sFilename, iType)
If (iType!=32) Then If (iType!=16) Then Return (0)
iBBSize = FileSize(sFilename)
If !iBBSize Then Return (0)
AddExtender("WWSER34I.DLL") ; The Serial Extender.
hBB = BinaryAlloc(iBBSize)
BinaryRead(hBB,sFilename)
iChecksum = pCheckBinary(IntControl(42,hBB,0,0,0),BinaryEodGet(hBB)-1,iType)
BinaryFree(hBB)
Return (iChecksum)
;..........................................................................................................................................
; This function "udfFileCrc" calculates the cyclic redundance checksum for type=16 or type=32.
;..........................................................................................................................................
; Detlev Dalitz.20010731.20020825
;..........................................................................................................................................
#EndFunction
:skip_udffilecrc
;------------------------------------------------------------------------------------------------------------------------------------------
;------------------------------------------------------------------------------------------------------------------------------------------
If ItemLocate("udffilecrc16",IntControl(77,103,0,0,0),@TAB) Then Goto skip_udffilecrc16
#DefineFunction udfFileCrc16 (sFilename)
iBBSize = FileSize(sFilename)
If !iBBSize Then Return (0)
AddExtender("WWSER34I.DLL") ; The Serial Extender.
hBB = BinaryAlloc(iBBSize)
BinaryRead(hBB,sFilename)
iChecksum = pCheckBinary(IntControl(42,hBB,0,0,0),BinaryEodGet(hBB)-1,16)
BinaryFree(hBB)
Return (iChecksum)
;..........................................................................................................................................
; Detlev Dalitz.20010730.20020825
;..........................................................................................................................................
#EndFunction
:skip_udffilecrc16
;------------------------------------------------------------------------------------------------------------------------------------------
;------------------------------------------------------------------------------------------------------------------------------------------
If ItemLocate("udffilecrc32",IntControl(77,103,0,0,0),@TAB) Then Goto skip_udffilecrc32
#DefineFunction udfFileCrc32 (sFilename)
iBBSize = FileSize(sFilename)
If !iBBSize Then Return (0)
AddExtender("WWSER34I.DLL") ; The Serial Extender.
hBB = BinaryAlloc(iBBSize)
BinaryRead(hBB,sFilename)
iChecksum = pCheckBinary(IntControl(42,hBB,0,0,0),BinaryEodGet(hBB)-1,32)
BinaryFree(hBB)
Return (iChecksum)
;..........................................................................................................................................
; Detlev Dalitz.20010730.20020825
;..........................................................................................................................................
#EndFunction
:skip_udffilecrc32
;------------------------------------------------------------------------------------------------------------------------------------------
;--- test ---
filename = IntControl(1004,0,0,0,0) ; We use this script as input file.
:test1
iCheck16 = udfFileCrc16(filename)
iCheck32 = udfFileCrc32(filename)
sMsgTitle = "Demo udfFileCrc16 (sFilename), udfFileCrc32 (sFilename)"
sMsgText = StrCat("udfFileCRC16(",filename,") = ",iCheck16,@LF,"udfFileCRC32(",filename,") = ",iCheck32)
Pause(sMsgTitle,sMsgText)
:test2
iCheck16 = udfFileCrc(filename,16)
iCheck32 = udfFileCrc(filename,32)
sMsgTitle = "Demo udfFileCrc (sFilename, iType)"
sMsgText = StrCat("udfFileCRC(",filename,",16) = ",iCheck16,@LF,"udfFileCRC(",filename,",32) = ",iCheck32)
Pause(sMsgTitle,sMsgText)
:CANCEL
Exit
;------------------------------------------------------------------------------------------------------------------------------------------
;*EOF*