include files in global.asa?

Discussion in 'ASP General' started by Tom Bates, Sep 10, 2003.

  1. Tom Bates

    Tom Bates Guest

    Possible? It seems nobody knows how...

    :)

    Tom
    Tom Bates, Sep 10, 2003
    #1
    1. Advertising

  2. Tom Bates

    Ken Schaefer Guest

    Why do you want to do that?

    Cheers
    Ken

    "Tom Bates" <> wrote in message
    news:...
    : Possible? It seems nobody knows how...
    :
    : :)
    :
    : Tom
    Ken Schaefer, Sep 10, 2003
    #2
    1. Advertising

  3. Tom Bates

    Tom Bates Guest

    I'd like to be able to do file cleanup in Session_OnEnd, and also have
    the same logic available on-demand from an ASP page. It's all about
    the code reuse, y'know? :)

    Tom

    On Wed, 10 Sep 2003 14:55:02 +1000, "Ken Schaefer"
    <> wrote:

    >Why do you want to do that?
    >
    >Cheers
    >Ken
    >
    >"Tom Bates" <> wrote in message
    >news:...
    >: Possible? It seems nobody knows how...
    >:
    >: :)
    >:
    >: Tom
    >
    Tom Bates, Sep 10, 2003
    #3
  4. Tom Bates

    Ken Schaefer Guest

    Call Session.Abandon in your "on demand" page, and Session_OnEnd will fire.
    Then you can just centralise your code in the global.asa file.

    Cheers
    Ken

    "Tom Bates" <> wrote in message
    news:...
    : I'd like to be able to do file cleanup in Session_OnEnd, and also have
    : the same logic available on-demand from an ASP page. It's all about
    : the code reuse, y'know? :)
    :
    : Tom
    :
    : On Wed, 10 Sep 2003 14:55:02 +1000, "Ken Schaefer"
    : <> wrote:
    :
    : >Why do you want to do that?
    : >
    : >Cheers
    : >Ken
    : >
    : >"Tom Bates" <> wrote in message
    : >news:...
    : >: Possible? It seems nobody knows how...
    : >:
    : >: :)
    : >:
    : >: Tom
    : >
    :
    Ken Schaefer, Sep 10, 2003
    #4
  5. Tom Bates

    Tom Bates Guest

    Well, I've finally gotten the answer I was looking for by crawling the
    web some more. Here's what I've learned, in case someone else could
    use this insight.

    1. global.asa doesn't recognize <% and %> tags.
    2. INCLUDE directives are HTML comments. So ASP has to be in HTML
    parsing mode at the point where the include directive HTML comment
    begins.
    3. The parsing of ASP pages, including global.asa, starts out in HTML
    mode, so you need <% (or <script> for global.asa) before code, and %>
    (or </script> in global.asa) to get back to HTML parsing mode.
    4. Subroutines at the beginning of global.asa are not handled
    properly, so put them at the end.
    5. option explicit comes before all code, including include files; if
    used, include files must obey the explicit rule too; option explicit
    can only be specified once, so don't put it in your include files

    Here's what now works for me:

    afunc.inc
    ---------
    <%
    function testit(b)
    dim avar
    avar = 1
    testit = b + avar
    end function
    %>

    apage.asp
    ---------
    <% option explicit %>
    <!-- #INCLUDE FILE="afunc.inc" -->
    <%
    dim t
    ( asp code )
    t = testit(4)
    %>

    global.asa
    ----------
    <script language="VBScript" runat="server">

    option explicit

    sub Application_OnStart
    (VBscript)
    end sub
    sub Application_OnEnd
    (VBscript)
    end sub
    sub Session_OnStart
    (VBscript)
    end sub
    sub Session_OnEnd
    dim what
    (VBscript)
    what = testit(11)
    end sub

    </script>
    <!-- #INCLUDE FILE="afunc.inc" -->
    Tom Bates, Sep 10, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wayne
    Replies:
    2
    Views:
    469
    Wayne
    Nov 11, 2003
  2. Andreas Bogenberger
    Replies:
    3
    Views:
    904
    Andreas Bogenberger
    Feb 22, 2008
  3. Tom Bates
    Replies:
    0
    Views:
    140
    Tom Bates
    Sep 8, 2003
  4. abcd

    include file in global.asa

    abcd, Sep 30, 2006, in forum: ASP General
    Replies:
    6
    Views:
    618
    Anthony Jones
    Oct 3, 2006
  5. Dave
    Replies:
    3
    Views:
    196
    Steven Cheng[MSFT]
    Oct 23, 2006
Loading...

Share This Page