Anthony said:
Hi Anthony Jones,
(btw - pws does support runat="server", don't blame the machine for our
lack of skills)
So if runat server is supported in PWS then the example I gave should work.
If I go through these steps exactly (can you follow them verbatim?) :-
Create a file called test.vbs in a folder (lets also call it test) under the
root folder of the local website:-
Function DoSomething(a, b)
DoSomething = a + b
End Function
Now in the same folder I create test.asp that has this content:-
<script src="test.vbs" runat="server" language="vbscript"></script>
<html>
<script src="test.vbs" type="text/vbscript"></script>
<script type="text/vbscript">
Function Body_Onload()
divLocal.innerHTML = "3 + 4 = " & DoSomething(3,4)
End Function
</script>
<body onload="Body_Onload()">
1 + 2 = <%=DoSomething(1,2)%>
<div id="divLocal" />
</body>
</html>
Now in IE6 I visit
http://localhost/test/test.asp
I see:-
1 + 2 = 3
3 + 4 = 7
but you get a type mismatch when excuteing DoSomething in <% %>. Which
indicates that the DoSomething function hasn't been created. If that's how
PWS (which is ASP 2.0) works there is little point in it supporting the
runat="server" attribute.
this line, will not work, it is not a valid line in asp rules.
the reason for that, is :
the following script will not work because ASP executes the #include
directive before it assigns a value to the variable.
ref: [
http://www.w3schools.com/asp/asp_incfiles.asp]
<%
<!-- #include file="test.vbs" -->
%>
Oh well it was a longshot based on the apparently the PWS not doing exactly
what I see in an IIS implementation.
Hi Anthony Jones,
i did exactly what you worte word by word:
1. i created the file test.asp with the relevant code.
2. i created the file test.vbs , in the same folder of step 1, with the
relevant code.
3. i rechecked that my pws supports <script runat="server" ...>, and it
does - i've an app that uses <script runat="server" ...>.
4. i rechecked that there are no security issues, and there are no
security on my pws.
5. i "mapped" the relevant virtual folder, and the results are i) & ii)
i)
on the ie 6.0 window i get:
-------------------------------------------------
| 1 + 2 = |
| |
| Microsoft VBScript runtime error '800a000d' |
| |
| Type mismatch: 'DoSomething' |
| |
| /dt/test.asp, line 10 |
-------------------------------------------------
ii)
on the ie 6.0 error message box -
- see ie menu tools/internet options/advanced/enable script error
notify... -
i get this:
-----------------------------------------
| Line: 6 |
| Char: 2 |
| Error: Object required: 'divLocal' |
| Code: 0 |
| URL: http:/127.0.0.1/dt/test.asp |
-----------------------------------------
So you susspect that my pws does not support the runat="server" solemn
attribute.
On my global.asa i use this attribute,
<script language="VBScript" runat="Server">
Sub Application_OnStart
</script>
<script language="VBScript" runat="Server">
<!-- #include file="incs/globalasa/globApsOSDefault.inc" -->
</script>
<script language="VBScript" runat="Server">
END Sub
</script>
<script language="VBScript" runat="Server">
Sub Application_OnEnd
</script>
<script language="VBScript" runat="Server">
<!-- #include file="incs/globalasa/globApsOEDefault.inc" -->
</script>
<script language="VBScript" runat="Server">
END Sub
</script>
(end of global.asa)
and for instance, on globApsOSDefault.inc:
<script language="VBScript" runat="Server">
' set application variables requires reboot
Application("countVisitors") = 0
Application("dateAppStarted") = now()
</script>
i think, correct me if i'm worng, that my pws does support
runat="Server",
but does not support functions defined in this manner of syntex:
<script runat="server" src="test.vbs" language="vbscript"></script>
a. what do you think, what other options have i got to get a valid run
of the line:
<script src="test.vbs" runat="server" language="vbscript"
type="text/vbscript">?
b. is the code line:
<script runat="server" language="vbscript" type="text/vbscript">
<!-- #include file = "test.inc" -->
</script>
is equal to:
<script src="test.vbs" runat="server" language="vbscript"></script>
regarding the order of execution and running the code on the server?
test.inc:
<%
Function DoSomething(a, b)
DoSomething = a + b
End Function
%>