|
-
May 29th, 2002, 01:47 PM
#1
Thread Starter
Black Cat
HOWTO: Use Multiple Scripting Languages on a ASP Page and call each other's functions
Yes, you can call a JScript Function for VBScript and vice versa. TIf you don't have Perl installed, snip out the apporpriate sections - and ASP or something tries to call a sub Write in PerlScript, so I had to stick in a dummy function to stop an error.
Code:
<% @LANGUAGE = "VBSCRIPT" %>
<script language="VBScript" runat="server">
Function testvbs()
Dim env
Response.Write "<table>"
Response.Write "<tr><th>From VBScript</th><td></td></tr>"
For Each env In Request.ServerVariables
Response.Write "<tr><th>"
Response.Write env
Response.Write "</th><td>"
Response.Write Request.ServerVariables(env).Item
Response.Write "</td></tr>" & vbcrlf
Next
Response.Write "</table>"
End Function
</script>
<script language="JScript" runat="server">
function testjs() {
var i;
Response.Write("<table>");
Response.Write("<tr><th>From JScript</th><td></td></tr>");
for (i = 1; i <= Request.ServerVariables.Count; i++) {
Response.Write("<tr><th>");
Response.Write(Request.ServerVariables.Key(i));
Response.Write("</th><td>");
Response.Write(Request.ServerVariables(i).Item);
Response.Write("</td></tr>\n");
}
Response.Write("</table>");
}
</script>
<script language="PerlScript" runat="server">
use strict;
use warnings;
use vars qw/$Response $Request/;
sub testps() {
my $i = 0;
$Response->Write("<table>");
$Response->Write("<tr><th>From PerlScript</th><td></td></tr>");
for ($i = 1; $i <= $Request->ServerVariables->{Count}; $i++) {
$Response->Write("<tr><th>");
$Response->Write( $Request->ServerVariables->Key($i) );
$Response->Write("</th><td>");
$Response->Write( $Request->ServerVariables->Item($i) );
$Response->Write("</td></tr>\n");
}
$Response.Write("</table>");
}
#Weird hack to prevent error for main::write
sub Write() {
}
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>ASP ENVIRONMENT</title>
<style type="text/css" media="all" title="Default">
html, body {
margin: 0px;
padding: 0px;
}
table {
margin: 10px;
border-collapse: collapse;
border: 1px solid black;
}
th {
border: 1px solid black;
font-family : Arial, Helvetica, sans-serif;
text-align : left;
vertical-align : middle;
}
td {
border: 1px solid black;
white-space : pre;
font-family : "Courier New", Courier, monospace;
text-align : left;
vertical-align : middle;
}
</style>
</head>
<body>
<p>VBScript:</p>
<% ScriptingNamespace.testvbs %>
<p>JScript:</p>
<% ScriptingNamespace.testjs %>
<p>PerlScript:</p>
<% ScriptingNamespace.testps %>
</body>
</html>
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|