You do not in fact need any special library to do CGI. All that CGI libraries do is decode the query string for you and, depending on the library, take care of the output headers. You can do all this yourself. However, QuickBASIC's primary output is not to the standard output device. Instead, it writes directly to the screen. What you need to do is open the character device file "CONS:" and send the text you want sent to the user there.
The response header set you need to send is interpreted by the server, so it does not need to be a full HTTP set of headers. A minimal response is the status header:
Status: ### description
Use number 200 for a valid, successful request. Here are some other codes you can use to help indicate the status of the response:
- 302: permanently moved (you need to specify the 'Location:' response header alongside this to specify where the resource has moved to)
- 401: authorization needed (this will make the client attempt to use HTTP authentication, which will require some base64 decoding to properly use).
- 403: forbidden (the client will not attempt to re-request the resource)
- 404: not found
- 500: internal server error
There are many others, and they are all listed in the HTTP RFC (#2068). There are some other headers you can specify, such as:
- Location: <url> (used in conjunction with status codes 302 and 305, as well as for specifying the filename when outputting binary data)
- Content-Type: <mime-type> (used to specify how the browser should treat the data, typically you want either "text/html" or "application/octet-stream"

- Content-Length: <number of bytes> (can help to optimize the browser's retrieval of the data, but is not strictly necesary)
There are also many other headers you can use. Most of the headers listed in the RFC should be valid here, including cache control headers.
Once you are done with the headers, output a blank line, and then start sending your content. It's as simple as that!
As for getting parameters from the request, avoid the "POST" method, as it is a headache to deal with manually (especially in multipart mode, and especially from QB). Use the "GET" method in forms, which will put all the parameters into the environment variable "QUERY_STRING" in the following form:
- each parameter is specified in the form name=value (or just name if value is not present)
- parameters are delimited by ampersands ('&')
- spaces have been turned into + signs, and a number of symbols including the following will have been turned into hex form: + = & % # /
Hex form consists of "%xx", where xx is a hexadecimal number. Replace the 3 characters with a single character whose ASCII code is the value of the hexademical number.
To parse the QUERY_STRING, first break it down into parts delimited by &. This will give you one part per parameter. Break each parameter down into parts delimited by =. This will give either one part (in which case it is a name), or two parts (in which case the first part is a name and the second part is a value). Take each of these parts and do the following (in this order):
- turn all +'s into spaces
- turn all %xx's into the corresponding characters
It seems a bit daunting, but once you've written it once, you can re-use the code in multiple CGI applications.
When it actually comes down to it, though, I recommend the PowerBASIC Console Compiler for writing CGI stuff in the QuickBASIC language. PBCC costs about $100 USD, if I recall correctly, and can be ordered online from
PBCC takes code that is very, very similar to QB code (they quote 98% compatible), and produces Win32 console binaries that run fairly efficiently (the compiler does some simple optimizations). The net result is that your CGI programs will load more quickly and run more quickly.
Anyway, good luck with your CGI endeavours

Ultimately, the future lies in technologies like Microsoft's ASP.NET, where your code is essentially integrated into the web server at runtime, but CGI is a good place to start, and it's good to get a good feel for what's going on behind the scenes.