ASP Help

Associate
Joined
22 Jan 2004
Posts
2,322
Location
Next to the ketchup...
Right colleague at work just sent me some webpages in ASP, There for viewing a variable and its value on a PLC but i seem to get an error when i'm trying to view the page.

The code looks like this:

<html>


<body text="#000080" bgcolor="#FFFFFF">

</body>

<input type="text" name="txtDave" value="1" size="1">

<!--meta http-equiv="refresh" content="2"-->

<form method="POST" action="/goform/ReadWrite">
<input type=hidden name=redirect size=50 value="index.asp">
<p align="center"><img border="0" src="JTSystemsSmall.gif" align="left"></p>
<p align="left">
&nbsp;</p>
<p align="left">
&nbsp;</p>
<p align="left">
<font face="Verdana">
<b>Read / Write PLC Variables</b> </font>
</p>
<p><font face="Verdana">Variable Name</font><br>
<input type="text" name="variable" value="<% WebPrint("var"); %>" size="20"></p>
<p><font face="Verdana">Value</font><br>
<input type="text" name="value" value="<% WebPrint("val"); %>" size="20"></p>
<p dir="ltr"><input type="submit" value="Read" name="read"><font face="Verdana"><input type="submit" value="Writing" name="write"></font></p>
<p>&nbsp;</p>
</form>

When i'm trying to view the page i'm getting a error that looks like this:

Error.JPG


I myself am not amazing at ASP, but i cant seem to see anything wrong with it... Anyone with a trained eye notice anything wrong?
 
I've not written classic ASP for a while, but you don't need the semi-colons after the function, and you need an = or Response.Write in front to write the function's return to the page.

Try:

<%= WebPrint("var") %>

Is var defined anywhere? At the moment you are passing the string "var" into the function. Is WebPrint defined anywhere?
 
Hmm think I need to sit and work this out for a bit, have just been sent these by someone else, I can't find if Var or webprint is defined anywhere.
 
Last edited:
Right, this is all sorted now, was missing a file on the PLC which contained the variables.

I have managed to sort out a kind of logon page before you can get to the main page, but what i really want to do is have it so you can view the main page straight away but if your not logged on, one of the buttons on the page that allows you to change the value of a variable on the PLC is disabled, but you can still view the current value of the variable.
 
you could do that easily enough using an if statement..

how does your logon work, session or cookie?
 
The logon is working as a session at the moment, think I might have it sorted, have set up the logon page to open first, and if the logon is incorrect or the user clicks the skip button they can go to the main page and still view the variables, but the write button is disabled, and have given them and option on the page to go back and login correctly and if they do, the write button becomes enabled.
 
Theres probably a really simple way to do this but i cant figure it out. I want to store the results from the two boxes on the main page

boxes.JPG


and write them to say a txt file... but i cant work it out for the life of me...
 
Yep pretty much, txt file or database I dont mind, just cant seem to figure it out.... not done asp in so long and then i have'nt done much on it lol
 
This is the Code from the main page:

<html>


<body text="#000080" bgcolor="#FFFFFF">

<form method="POST" action="/goform/ReadWrite">
Dim objFSO, objTextFile
Dim sRead, sReadLine, sReadAll
Const ForReading = 1, ForWriting = 2, ForAppending = 8
<input type=hidden name=redirect size=50 value="index.asp">
<p align="center"></p>
<p align="left">
&nbsp;</p>
<p align="left">
<img border="0" src="Current%20PLC%20Website/Web/plclogo.jpg" align="center"></p>
<p align="left">
<font face="Verdana">
<b>Read / Write PLC Variables</b> </font>
</p>
<p><font face="Verdana">Variable Name</font><br>
<input type="text" name="variable" value="<% WebPrint("var"); %>" size="20"></p>
<p><font face="Verdana">Value</font><br>
<input type="text" name="value" value="<% WebPrint("val"); %>" size="20"></p>
<font face="Verdana"><p dir="ltr"><input type="submit" value="Read" name="read"></p>
<% UserGroup(2); %>
<p><input type="submit" value="Writing" name="write"></font></p>
<p>&nbsp;</p>
<% UserGroup(0); %>
</form>

<form method="POST" action="/goform/UserLogout">
<input type=hidden name=redirect value="login.asp">
<p><b>User-Logout:</b></p>
<p><input type="submit" value="Logout"></p>
</form>
</body>

<input type="text" name="txtDave" value="1" size="1">

The above currently works fine and does everything i want it to. The two variables being used above "Var" and "Val" are declared on another page. So I had a look at that link you sent me, and have peiced together the code to what I think suits my needs...

Dim objFSO, objTextFile
Dim sRead, sReadLine, sReadAll
Const ForReading = 1, ForWriting = 2, ForAppending = 8

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile("c:\valuesandvariables.txt", True)

' Write a line.
objTextFile.Write ("This line is written using Write().")

objTextFile.Close

' Open file for reading.
Set objTextFile = objFSO.OpenTextFile("c:\valuesandvariables.txt", ForReading)

' Use different methods to read contents of file.
sReadLine = objTextFile.ReadLine
sRead = objTextFile.Read(4)
sReadAll = objTextFile.ReadAll

objTextFile.Close

Not entirley sure where all the above is suppose to go as wherever i seem to put it, it dosent work...

I need to take the value of the two variables "Var" & "Val" and write them to the text file, so this is probably completly wrong but here goes:

objTextFile.Write ("Var().")

??? Even close??
 
Back
Top Bottom