HASH-CODE function
- Last Updated: February 11, 2026
- 3 minute read
- OpenEdge
- Version 13.0
- Documentation
Returns a hash code, as an INTEGER value, for one or more arguments. The
HASH-CODE function is intended to be used in objects that are
part of a hash-based collection, that is, those that implement the Progress.Collections.IHashable interface or the Progress.Collections.IEqualityComparer<T> interface.
Syntax
|
- arg
- An expression of any of the data types allowed when defining a variable.This includes
scalar data types, object-oriented ABL object types, and the Unknown value
(
?). BLOB/CLOB types are not supported.The function accepts up to 10 arguments. If you need more than 10 arguments, you can calculate the hash code for the first 10, and then feed the result into another call to
HASH-CODE.
Example
The following code example uses the HASH-CODE function to generate a hash
code based on a first and last name.
|
Notes
- This function is intended for use with hash-based collections only.
- The hash code returned by the
HASH-CODEfunction is consistent within a given ABL session. Once the ABL session is restarted, there is no guarantee that the hash code will be the same. Therefore, it is strongly recommended that you do not store or pass the hash code between sessions, as the value may not be the same while executing in different sessions. - The
HASH-CODEfunction is provided specifically to support hash-based collection within a given session and is not a replacement for theENCODEfunction, nor is it suitable for any cryptography tasks. Its sole purpose is to provide a hash code that can be used with hash-based collections. - The order of the arguments can change the resulting hash code value. Therefore, if comparing the value returned by the function, be consistent with the order of the parameters.
- Any two values that return TRUE when compared with the
EQoperator in ABL return the same hash code. Simply put, given two values, val1 and val2, if the expressionval1 EQ val2returns TRUE, thenHASH-CODE(val1) EQ HASH-CODE(val2)is also true. - The format of a given field or variable does not impact the calculation of the hash code, only the actual data does.
- A given integer value returns the same hash code whether it is represented using either the INTEGER or INT64 data type (assuming the value does not overflow the INTEGER data type).
- A given decimal value with no significant decimal places (that is
5 EQ 5.00returns TRUE) returns the same hash code regardless of the number of decimal places specified. - Values of type CHARACTER and LONGCHAR generate the hash code respecting the case-insensitiveness of the values. That is, a value of either one of those data types generate the same hash code if two case-insensitive strings are considered equal. If the value is case-sensitive, the hash code is not expected to be the same as another value that is case-insensitive, unless both strings match exactly.
- LONGCHAR strings of different code pages are always converted to the codepage
specified by the
-cpinternalstartup parameter for comparison and return the same hash code if they are considered to be equal by the AVM. - For MEMPTR values,
HASH-CODEuses all the bytes stored in the memptr, as defined by its size (as returned by theGET-SIZEfunction) when generating the hash code. All other data types use the data as provided by the expression that generated them. - When passing an object-oriented ABL object as an argument to the
HASH-CODEfunction, the AVM checks if the object implements theProgress.Collection.IHashableinterface, in which case it calls theHashCode()method to get the hash code for that object instance. If the object does not implement such interface, the AVM uses an internally generated value that is guaranteed not to change while the object is still in scope.
See also
Progress.Collections.IHashable interface, Progress.Collections.IEqualityComparer<T> interface