Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I want to create a custom formula, and it is not working. I press CTRL M and enter my formula code below (which I got from another source, and it should be correct) then click OK.
After that when I go to my script and enter this new function, and it does not understand it. it is underlined as incorrect. How do I make the script recognize it? What am I missing?
Function levenshtein( a, b )
Dim i,j,cost,d,min1,min2,min3
' Avoid calculations where there there are empty words
If Len( a ) = 0 Then levenshtein = Len( b 😞 Exit Function
If Len( b ) = 0 Then levenshtein = Len( a 😞 Exit Function
' Array initialization
ReDim d( Len( a ), Len( b ) )
For i = 0 To Len( a 😞 d( i, 0 ) = i: Next
For j = 0 To Len( b 😞 d( 0, j ) = j: Next
' Actual calculation
For i = 1 To Len( a )
For j = 1 To Len( b )
If Mid(a, i, 1) = Mid(b, j, 1) Then cost = 0 Else cost = 1 End If
' Since min() function is not a part of VBScript, we'll "emulate" it below
min1 = ( d( i - 1, j ) + 1 )
min2 = ( d( i, j - 1 ) + 1 )
min3 = ( d( i - 1, j - 1 ) + cost )
If min1 <= min2 And min1 <= min3 Then
d( i, j ) = min1
ElseIf min2 <= min1 And min2 <= min3 Then
d( i, j ) = min2
Else
d( i, j ) = min3
End If
Next
Next
levenshtein = d( Len( a ), Len( b ) )
End Function
Seems to work for me if I use something like
| LOAD | levenshtein('Stefan','Steffen') as Test |
Autogenerate 1;
It is still treating the script as an error:

Perhaps the problem is that I am using Personal Edition and one of my settings needs to change
Have you tried to run the script?
Hi,
Can you just click the 'Check' Button in the 'Edit Module' and try that?