Active Server Pages for Windows CE
This sample is a special form of Sample 3. Therefore, please first familiarize yourself with the methodology described in Sample 3.
Windows CE can serve as a web server for ASP pages (by copying the appropriate files into the "WWW" directory). However, the functionality of this is limited, which manifests itself in the fact that on Windows CE the "global.asa" file cannot be processed. Thus, among other things, it is not possible to create global variables and objects; they must be created anew for each page call by instantiating them directly in the script (as shown below).
default.asp:
<%@ language=JScript %>
<%
TcClient = new ActiveXObject("TcScript.TcScriptSync");
TcClient.ConnectTo("", 801);
var nIntSet = 0;
var nIntActual = 0;
var sSet = Request.QueryString("set");
if ((sSet != null) && (sSet.length != 0))
{
var bSetIsNumber = true;
for (var i = 0; ((i < sSet.length) && (bSetIsNumber == true)); i++)
{
var sChar = sSet.charAt(i);
if (ValidChars.indexOf("0123456789.") == -1)
{
bSetIsNumber = false;
}
}
if (bSetIsNumber == true)
{
nIntSet = parseInt(sSet);
if(nIntSet >= 0)
{
TcClient.WriteVar(".PLCVarInt", nIntSet);
}
}
}
nIntActual = TcClient.ReadVar(".PLCVarInt");
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>TwinCAT ADS-Script-DLL - Sample 04 - Windows CE</title>
</head>
<body>
<h1>TwinCAT ADS-Script-DLL - Sample 04 - Active Server Pages for Windows CE</h1>
<form method="get" action="default.asp" name="tempSet">
set: <input name="set" size="4" value="<% Response.Write( nIntSet ); %>">
</form>
actual: <% Response.Write( nIntActual ); %>
</body>
</html>
Presentation in Internet Explorer:
The HTML page sent to the client (Internet Explorer):
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>TwinCAT ADS-Script-DLL - Sample 04 - Windows CE</title>
</head>
<body>
<h1>TwinCAT ADS-Script-DLL - Sample 04 - Active Server Pages for Windows CE</h1>
<form method="get" action="Sample04.asp" name="tempSet">
set: <input name="set" size="4" value="3">
</form>
actual: 3
</body>
</html>
Unpack sample program ADS-Script-DLLSAmple04.zip 'Active Server Pages for Windows CE'.