I know, why the heck would you have to do this? Well, here’s how you would do it:
< %
Option Explicit
’ This redefines the “left” function
’ Yes, it’s hard to defend this kind of
’ overriding of native VBScript functions
Function Left(mystring,mynumber)
Left = Right(mystring,mynumber)
End Function
Dim sc, cmd
’ This code is the way to get to the “real” old version
set sc = CreateObject(“MSScriptControl.ScriptControl”)
’ set the language
sc.Language = “VBScript”
’ what command do you want to call?
cmd = “Left(“”hello”“,1)”
Response.Write Eval(cmd)
Response.Write “,”
Response.Write Left(“hello”, 1)
Response.Write “,”
’ here we call the one that produces the right result
Response.Write sc.Eval(cmd)
%>
Output:
o,o,h

3 comments
Comments feed for this article
Trackback link
http://artlung.com/blog/2006/11/01/what-if-you-have-to-un-override-a-native-vbscript-function/trackback/
November 2, 2006 at 12:48 pm
Sassy
you never answered the question… why would you want to do this?
November 2, 2006 at 12:53 pm
Joe Crawford
Because the codebase has 8 year old nuggets where mofos do stuff like rewrite the NumberFormat function, and if you want to get to the actual functionality of the NumberFormat function, you have to do this silly thing.
I like to think of it like function or operator overloading, but much, much stupider, because you lose the original functionality.
November 2, 2006 at 5:06 pm
Sassy
wow that is insanity! I am always amazed at the stuff people do.