PenGuide 2: How To Adapt PenDraw
to Get Form Data via CGI (Common Gateway Interface)
Version 1, Andrew Main, 21 November 2005
Assume that
you have a simple web page such as this:
<html>
<body>
<form action="http://localhost/helloworld.pdrs" method="post">
My Lady<br>
Beauty
<input type="text" name="beauty"
value="superb"><br>
Nature
<input type="text" name="nature"
value="loving"><br><br>
<input
type="submit">
</form>
</body>
</html>
When the
user clicks the submit button, an HTTP request will go to the web server at localhost (ie the computer you are
using). The request will include the
fact that helloworld.pdrs is to be executed, and the form data. (It is not very important, but in case you
have heard about scripting and you are wondering how this all fits in, you
might like to know that in CGI terms, helloworld.pdrs is a script.)
Three key things for your helloworld.pdrs album
Output must go to “stdout”. You need to make
sure that your output goes to a “file” with an empty name, like this (you do
not have to stick to channel 1, you can use any number
from 1 through 255. We tend to use 1.)
Open "" For Output As 1
To get Form Data you must use the WebData construct in your program.
Here are the lines that we added, to show the form data in helloworld.pdrs
Dim
SSS as String
SSS = WebData
"beauty" as String
Draw {Pp 7,At
(200,200),Width 5} NoteNo(1,SSS)
SSS = WebData
"nature" as String
Draw {Pp 7,At
(200,190),Width 5} NoteNo(1,SSS)
Do NOT use SvgZ.
We have not found the right MIME type for SvgZ,
yet. We will do so and we will update
this PenGuide as soon as we have found it. For now, if you use SvgZ,
IIS simply moans at you that it does not like the output! It may well be that we are compressing the
Content-type, and need to change the way we do things a little. We will crack it!