VodkaScript
Programming code that is written so poorly that it could only have been written by someone after that person drank an entire bottle of vodka. It runs without error, however, it may be overly inefficient, useless, or a re-implementation of a function that already exists as part of the programming language.
VBScript example written in VodkaScript:
Function CleanQuotes(InputString)
Dim OutputString
Dim Position
For Position = 1 to Len(InputString)
If Mid(InputString, Position, 1) = "'" Then
OutputString = OutputString & "''"
Else
OutputString = OutputString & Mid(InputString, Position, 1)
End If
Next
CleanQuotes = OutputString
End Function
----------------
VBScript sample written correctly using built-in function:
Dim strVariable ' contains some unwanted character
strVariable = Replace(strVariable, "(unwanted character)", "(replacement character(s))")
Where (unwanted character) is any character(s). i.e. '",@!$ (in the case of a double-quote, use two double-quotes)
----------------
The way that the VodkaScript sample above should have been written, for efficiency and re-use, is:
Function CleanQuotes(InputString)
CleanQuotes = Replace(InputString, "'", "''")
End Function
Function CleanQuotes(InputString)
Dim OutputString
Dim Position
For Position = 1 to Len(InputString)
If Mid(InputString, Position, 1) = "'" Then
OutputString = OutputString & "''"
Else
OutputString = OutputString & Mid(InputString, Position, 1)
End If
Next
CleanQuotes = OutputString
End Function
----------------
VBScript sample written correctly using built-in function:
Dim strVariable ' contains some unwanted character
strVariable = Replace(strVariable, "(unwanted character)", "(replacement character(s))")
Where (unwanted character) is any character(s). i.e. '",@!$ (in the case of a double-quote, use two double-quotes)
----------------
The way that the VodkaScript sample above should have been written, for efficiency and re-use, is:
Function CleanQuotes(InputString)
CleanQuotes = Replace(InputString, "'", "''")
End Function