[Coco] The Coco's first webserver, written in Basic09
Christian Lesage
hyperfrog at gmail.com
Thu Dec 31 00:11:03 EST 2009
Wayne Campbell wrote:
> I was beginning with simply parsing an expression. I felt that if I
> could accomplish this, the rest would be easier to figure out. The
> problem with RUN is that it specifically launches a subroutine module
> (Basic09 I-Code or 6809 object code), passing to it whatever
> parameters are required. This means that the eval() function , in the
> statement RUN eval(<string>), is a subroutine that does whatever
> parsing is necessary to evaluate the "expression". The parameter, in
> this case, would be the string to parse.
Forget about eval(). Let's say you authored the following web page:
<HTML>
<BODY BGCOLOR=#33FF33>
<P><CENTER><H1>coco!</h1><P>
<H4>This page is served by a Color Computer 3<BR>
running <A HREF=http://www.nitros9.org/>NitrOS-9</A>
and <A HREF=http://www.frontiernet.net/%7Emmarlette/Cloud-9/Software/DriveWire3.html>DriveWire</A>
<P>For more information on this
project, <A HREF=http://aaronwolfe.com/coco>click here</A><P>
This server has processed <% PRINT #port_path,hits \ hits = hits + 1 %> requests since it last crashed.</H4>
</BODY>
</HTML>
And you have a program that converts that HTML code into this:
PROCEDURE SomeWebPage
PARAM port_path:BYTE
PARAM hits:INTEGER
PRINT #port_path,"<HTML>"
PRINT #port_path,"<BODY BGCOLOR=#33FF33>"
PRINT #port_path,"<P><CENTER><H1>coco!</h1><P>"
PRINT #port_path,"<H4>This page is served by a Color Computer 3<BR>"
PRINT #port_path,"running <A HREF=http://www.nitros9.org/>NitrOS-9</A>"
PRINT #port_path,"and <A HREF=http://www.frontiernet.net/%7Emmarlette/Cloud-9/Software/DriveWire3.html>DriveWire</A>"
PRINT #port_path," <P>For more information on this project, <A HREF=http://aaronwolfe.com/coco>click here</A><P>"
PRINT #port_path,"This server has processed "
PRINT #port_path,hits \ hits = hits + 1
PRINT #port_path," requests since it last crashed.</H4>"
PRINT #port_path,"</BODY>"
PRINT #port_path,"</HTML>"
END
Such a converter would be easy to write. It merely wraps the HTML code
inside quotation marks and adds PRINT statements. It leaves untouched
anything between <% and %>.
Now, you compile the resulting PROCEDURE into bytecode, and it becomes
the active page that the server RUNs whenever it needs to display it.
Yes, I know, for some reason, a BYTE cannot be passed as a parameter.
This is just an example to illustrate what I'm thinking about. I guess
one would define in the main program a structure to be passed as a
parameter to every page.
More information about the Coco
mailing list