[Overview][Constants][Types][Procedures and functions][Variables][Index] Reference for unit 'objpas' (#rtl)

Hash

Create GNU Gettext hash value for a string

Declaration

Source position: objpas.pp line 94

function Hash(

  S: AnsiString

):LongWord;

Description

Hash calculates the hash value of the string S in a manner that is compatible with the GNU gettext hash value for the string. It is the same value that is stored in the Resource string tables, and which can be retrieved with the GetResourceStringHash function call.

Errors

None. In case the calculated hash value should be 0, the returned result will be -1.

See also

GetResourceStringHash

  

Return hash value of resource string

Example

Program Example93;

{ Program to demonstrate the Hash function. }
{$Mode Delphi}

ResourceString

  First  = 'First string';
  Second = 'Second String';

Var I,J : Longint;

begin
  For I:=0 to ResourceStringTableCount-1 do
    For J:=0 to ResourceStringCount(i)-1 do
      If Hash(GetResourceStringDefaultValue(I,J))
        <>GetResourceStringHash(I,J) then
        Writeln ('Hash mismatch at ',I,',',J)
      else
        Writeln ('Hash (',I,',',J,') matches.');
end.
The latest version of this document can be found at lazarus-ccr.sourceforge.net.