Mega Code Archive

 
Categories / Delphi / Strings
 

Convert a String to an Unique number

Title: Convert a String to an Unique number? /////////////////////////////////////////////// //This function Convert a string to a number, //is useful when you need to index strings. //Every string will become a different number. /////////////////////////////////////////////// type UInt64 = 0..9223372036854775807; function Unc(s: string): UInt64; var x: Integer; begin Result := 0; for x := 1 to Length(s) do Result := Result + ((Ord(s[x])) shl ((x - 1) * 8)); end;