I created a class in asp and wanted to know if it was possible to create a function or sub named "END". Is this possible even as a sub or function. The reason I wanted to call this for my class instance or class module like MyClass.End is to then call response.end?
Or is it possible to overide the response.end function to first check something before ending?
class Myclass
sub write(dim str)
response.write(str)
end write
' Is this "END" possible?
sub end
response.end
end sub
End class
Correction
This is not a valid subroutine declare : sub write(dim str)
Dim statement cannot be used to declare parameters. You should use ByRef or ByVal. Default is ByRef if not specified.
And end write
should be end sub
.
See instructions from MSDN : Sub Statement
Trick
When you need to use a reserved keyword for property or method name in the classes, you can declare it with brackets. Then you can call without brackets.
Here the example:
Class Myclass
Sub Write(str)
Response.Write str
End Sub
Sub [End] 'with brackets
Response.End
End Sub
End Class
Set o = New Myclass
o.write "what's up?"
o.end 'without brackets
Response.Write "..." 'this will not be printed
end
is a reserved word for vbscript (what classic ASP is based on) so no. This is a list of reserved words... http://support.microsoft.com/kb/216528