Share via


SYS(2007) - Checksum Value

Returns the checksum value of a character expression. You can use a checksum to test the validity of data or to compare two character expressions. You can also generate checksum values greater than 16 bits for large strings.

SYS(2017) offers complementary functionality by generating checksum values based on the current record in the current work area. For more information, see SYS(2017) - Record Checksum Value.

SYS(2007, cExpression, [, nSeed, [, nFlags]])

Parameters

  • cExpression
    Specifies a character expression (string) for which SYS(2007) returns a checksum value.

  • nSeed
    Specifies a numeric seed value of 0 that is used to calculate the checksum and is included for backward compatibility. Passing a value of -1 for nSeed uses the default system value of 0. For CRC32 calculations, Visual FoxPro disregards nSeed.

  • nFlags
    Set an additional bit value for generating the checksum.

    Versions of Visual FoxPro earlier than 8.0 used a CRC16 16-bit algorithm to calculate the checksum values of strings. Visual FoxPro now includes the CRC32 routine to calculate larger 32-bit values. You can control the setting of this algorithm by setting the first bit value of the nFlags parameter.

    The following table lists the bit value you can set to produce one of the values for nFlags.

    Value Bit Description
    1 001 Calculate checksum value using CRC32 checksum algorithm.

    The following table lists the possible values for nFlags, produced by setting the bit flag.

    nFlags Description
    0 Calculate checksum based on cExpression parameter using CRC16 checksum algorithm. (Default)
    1 Calculate checksum based on cExpression parameter using CRC32 checksum algorithm.

    For example, if you want use checksum using the CRC32 checksum algorithm to calculate the checksum based on cExpression, you should specify an nFlags value of 1. To use the CRC16 checksum algorithm, set the nFlags value to 0.

Return Values

Character data type

See Also

SYS( ) Functions Overview | SET RESOURCE | Creating Character Expressions