Versions: 6.7, 6.8 and 2003
This tech tip will show a quick method to compare blobs. As a developer, you may want to track any changes that occur to records. Being able to compare blobs will provide a developer the means to track the slightest modification.
Let's begin with the most obvious change. If the sizes are different then you know there has been a modification. However, two blobs with the same size may contain different values. To detect this, you will need to compare each byte of the blob against the other. Here is a simple project method to compare two blobs:
`Method Name: compareBlob
`Description: This method will compare the content of two blobs
` $1 = Blob; $2 = Blob
` $0: True if equal, otherwise false
If (BLOB size($1)=BLOB size($2))
For ($vByte;0;BLOB size($1)-1)
$vByte:=BLOB size Else
Method Call Example:
TEXT TO BLOB("hello world";vBlob1;3)
TEXT TO BLOB("hello World";vBlob2;3)
In this example, I am using just a text comparison. This example method will create two BLOBs and pass them into the compareBlob method and return a Boolean. You will notice that the text is "hello world" in both cases, so the total blob size will be the same. But the second blob has a capitalized W, which will return false.