include files in global.asa?

K

Ken Schaefer

Why do you want to do that?

Cheers
Ken

: Possible? It seems nobody knows how...
:
: :)
:
: Tom
 
T

Tom Bates

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
 
K

Ken Schaefer

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

: 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"
:
: >Why do you want to do that?
: >
: >Cheers
: >Ken
: >
: >: >: Possible? It seems nobody knows how...
: >:
: >: :)
: >:
: >: Tom
: >
:
 
T

Tom Bates

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" -->
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top