tags:

views:

57

answers:

2

This line:

set Response = nothing

Fails with the error

"Microsoft VBScript runtime  error '800a01b6'

Object doesn't support this property or method: 'Response' "

Now, I can think of any number of reasons why the engine might not want to let me do such a seemingly silly thing, but I'm not sure how a missing method could be stopping me.

EDIT: Here is an example of what I'd like to do with this.

class ResponseBufferEphemeron
    private real_response_
    private buffer_

    private sub class_initialize
        set real_response_ = Response
    end sub

    private sub class_terminate
        set Response = real_response_
    end sub

    public function init (buf)
        set buffer_ = buf
        set init = me
    end function

    public function write (str)
        buffer_.add str
    end function
end class

function output_to (buf)
    set output_to = (new ResponseBufferEphemeron).init(buf)
end function

dim buf: set buf = Str("Block output: ") ' My string class '
with output_to(buf)
    Response.Write "Hello, World!"
end with 

Response.Write buf ' => Block output: Hello, World! '
A: 

You can't set the Response to nothing.

The ASP Response object is used to send output to the user from the server.

What are you trying to do? If you're trying to end the Response to the user, use

Response.End
Ed B
"Can't" as in absolutely-prohibited-by-the-engine?I'm actually trying to do something unorthodox that involves redirecting Response.Write for a small templating system I'm fiddling with. I want all Response.Write calls within a block to be sent to a different object.This may be, and in fact probably is, a terrible idea for a number of reasons, but I'd like to get it working anyway, partly for the hell of it and partly because I won't be able to convince myself that it's a terrible idea until I've gotten it to successfully blow up in my face.
Thom Smith
A: 

Well, I found the answer here: http://blogs.msdn.com/b/ericlippert/archive/2003/10/20/53248.aspx

So we special-cased VBScript so that it detects when it is compiling code that contains a call to Response.Write and there is a named item in the global namespace called Response that implements IResponse::Write. We generate an efficient early-bound call for this situation only.

Thom Smith