functionasp-classicvbscriptdefined

Is there any way to check to see if a VBScript function is defined?


This is probably just wishful thinking...

Is there any way to check to see if an ASP/VBScript function is defined before calling it?


Solution

  • Here is my solution which works on the same principle, but the hacky-ness is pretty self-contained:

    Function FunctionExists( func_name )
        FunctionExists = False 
    
        On Error Resume Next
    
        Dim f : Set f = GetRef(func_name)
    
        If Err.number = 0 Then
            FunctionExists = True
        End If  
        On Error GoTo 0
    
    End Function