KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Code Snippet: Utility method for comparing blobs
PRODUCT: 4D | VERSION: 13.0 | PLATFORM: Mac & Win
Published On: November 20, 2012

One of the new features of v13 is the GENERATE DIGEST command which allows the generation of MD5 and SHA1 digests - using this command we can easily compare two blobs to see if the are the same.

Here is the utility method for comparing two blobs using the GENERATE DIGEST command:


C_BOOLEAN($0)
C_BLOB($1;$2)
If (Count parameters=2)
   $0:=(GENERATE DIGEST($1;MD5 Digest)=GENERATE DIGEST($2;MD5 Digest))
End if


If the code above is saved as aproject method named UTIL_Blob_Compare then it could be used like this:

C_BLOB($blob1;$blob2)
If (UTIL_Blob_Compare ($blob1;$blob2))
    // blobs are the same

Else
    // blobs are NOT the same

End if