CGI Workerman 1.3
HTML Converter for CGI Workerman 1.0

CGI Workerman 1.3

This module is designed to help you writing a CGI program with Visual Basic. There are over 10 functions in this module, you can use them to process user data, cookies and URL encoding/decoding. Here is a list of these functions, and basic usages of them.

Param(Key As String) As String: Read a form field's value from client.
Usually use it to read value from Textfield, Radio Button Group. Example: You have a tag like this '<INPUT TYPE="TEXT" NAME="USERNAME">' in your HTML form and a user typed his name, "Bob", in this text box. After he pushes 'Submit' button (Your script starts now), you can use Param("USERNAME") to read his name. In this situation, it will return "Bob". Notice that Key parmeter is NOT case sensitive. I mean, Param("username") will also return "Bob" in this situation.

ParamExist(Key As String) As String: Return True/False depending a form field is exist.
Usually use it to read value from Checkbox. Example: You have a tag like this '<INPUT TYPE="CHECKBOX" NAME="ISMEMBER">' in your HTML form and a user checked it. After he pushes 'Submit' button, you can use this function to identify if this checkbox is checked. In this situation, it will return TRUE. but if he didn't checked it, it will return FALSE. The Key parmater is also NOT case sensitive.

SendHeader(Text As String): Send a header line to client.
Use this subroutine to generate HTTP headers. In normally cases, you need to do this before you send any data to client:
SendHeader("HTTP/1.0 200 OK") ' All the situation is OK.
SendHeader("Content-type: text/html") ' This program will generate a HTML format data for response.
Note this module will calcuate output data's length and automatically send it and current date/time in GMT format to client, you don't need to do that yourself.

Send(Text As String): Send a line with CR/LF as response to client.
Use this subroutine to send your response data to client. Example:
Send("<HTML><HEAD><TITLE>Hello World</TITLE></HEAD>")
Send("<BODY><H1>Hello World</H1></BODY></HTML>")
It's just a "Hello World" example.

Response(Text As String): Send a line WITHOUT CR/LF as response to client.
Like Send(), but it doesn't insert a CR/LF at line end. Example:
Send("Line1"):Send("Line2") ' Send two line of text
Line1
Line2
But Response("Line1"):Response("Line2") ' Send two strings in a line
Will get "Line1Line2" As Output.

SetCookie, Cookie, CookieExist: Cookie processing utilities. Please look at the module for more info.
URLEncode, URLDecode: Encode or Decode a HTTP-Escaped string.
It's useful when you want to generate a link to another (self) CGI program. Example:
Send("<A HREF=""/cgi-bin/userdata.exe" & URLEncode(username) & "&" & URLEncode(password) & """>")
' It's a link to another CGI program with two pre-generated arguments.

WebDate(DateTime As Any Valid Date/Time Format): An easy way to generate HTTP-standard GMT times.
It's useful when you need to specify an expiration date for this document. Example:
GMTOffset=28800 ' Current time zone is GMT +8 hrs (28800 seconds)
Print WebDate("10/09/98 21:17:00") ' Convert local time to HTTP-standard format
Fri 09 Oct 1998 13:17:00 GMT
If you want to set expriration date for this output, simply do this:
SendHeader("Expire: " & WebDate(DateAdd("H",2,Now))) ' This document will expire after 2 hours
Of course, If you want to set exactly expiration for a cookie (see SetCookie in module), you can also use DateAdd function.

This module will load most useful server environments to a set of variables. For more information on this, please take a look at InitializeCGI() subroutine in this module.


HTML Converter for CGI Workerman 1.0

In normal situations, you must manually enter HTML codes in your CGI program, you can't use other WYSIWYG programs to design it. If you want to use a ready HTML file for response page, you must make some modify before you import it (Example: you must add Send() in each line, and change any double-quote symbols to two double quotes, like this: (") -> ("") ). So I designed this module to automatically convert any HTML file to CGI Workerman's code format. It will take a less time to edit response HTML files. Call it with two arguments: Source File and Destination File. It will read from source file, and put converted data to destination file, so the source file will not be modified. After convertion, you can import destinataion file you specified as program code. (copy/paste) It will auto convert any ASP-Like tag (<% ... %>) to normal VB program code, so you can edit entire page/program outside VB, convert it then compile it. Here is an Example page you can see how to make a page that compatible with this module. Anything inside (<%...%>) is treated as VB program code.

<% Sub CGI_Main() %>
.....HTML head/title.....
<% Select case param("action")
case "situation1" %>
.....HTML codes for situation 1.....
<% case "addfile" %>
.....HTML codes for situation 2.....
<% case "delfile" %>
.....HTML codes for situation 3.....
<% End Select %>
.....HTML footer......
<% End Sub %>


At the end of this document, I appreciate you to use my modules. These are all FREEWARE, You can send $10 support for this software if you like, but it's not needed. So feel free and enjoy it. For any suggestments or comments, please e-mail to: Wei-dun Teng <tiberius@ms13.url.com.tw>
If you like this software, please send a postcard to me. It's the power that let me make these software better and better!

Wei-dun Teng
4F No. 14, Lane 165 Alley 25, Sec.3 of Kang-Ning Road.
Taipei, Taiwan, Republic Of China.