CalcChecksum Procedure

Returns the Checksum value of a string or a file.

Syntax

[ nStatus = ] CalcChecksum ( sStr, nType, plResult )

The CalcChecksum procedure syntax has the following parts:

 

Name

Type

Description

nStatus

Short

Status. The Return value is 1 for success and 0 for an error while accessing the file.

sStr

Val BString

String or file name

nType

Val Short

Checksum type. This can be 8, 16 or 32 for calculating 8, 16 or 32 bits addition of the available bytes in the given string. Setting the first bit of iType to '1' (9, 17 or 33) indicates that sStr contains a file name.

plResult

Var Long

Return checksum value. The plResult is always 32 bit result (Long) of the sum of the Bytes, Ints or Longs in the file.

Comments

The CalcChecksum function can be used to ensure validity of data in communication transfers or files.

Example

if CalcChecksum(GetDir(aGetDirATEasy)+"\\ateasy.exe", 9, lChkSum)=0

MsgBox("Unable to CalcChecksum on ATEASY.EXE.

Aborting...")

Abort

elseif lChkSum <> CS_ATEASY

MsgBox("Corrupted ATEASY.EXE. Aborting...")

Abort

endif

See Also

Abort, GetDir, MsgBox