Discrimination of Forth versus perl

  • Thread starter Albert van der Horst
  • Start date
A

Albert van der Horst

I am trying to do some web scripting in Forth
This is a transcript of the perl
example from O'Reilly (Gundavaram) CGI-programming pg. 17.

With the multiple line strings and the occasional
auxiliary word, it looks neater than perl IMO.

However, no environment variables can be accessed from the
script apparently. The corresponding perl script has no
such problems. (Environment available in an associative
array %ENV ).
What is going on here?

[For those unacqainted with CGI, these are scripts that
generates html "on the file". With variable content.]


---------8<----------------8<--------------
#!/usr/bin/lina -s

\ Using server site scripting in Forth.

\ ---------- requisites -----------------
REQUIRE GET-ENV
\ Print environment variable from its NAME.
: .ENV GET-ENV TYPE "<BR>" TYPE CR ;

\ --------- push the scripts prelude --------------
"Content-type: text/html

<HTML>
<HEAD><TITLE> About this server</TITLE></HEAD>
<BODY>
<H1>About this server</H1>
<HR>Welcome to Albert's brave new world of Forth scripting!<HR>
<PRE>
" TYPE

\ --------- push information ---------------------
"Server Name: " TYPE "SERVER_NAME" .ENV
"Running on port: " TYPE "SERVER_PORT" .ENV
"Server SOFTWARE: " TYPE "SERVER_SOFTWARE" .ENV
"Server PROTOCOL: " TYPE "SERVER_PROTOCOL" .ENV
"CGI Revision: " TYPE "GATEWAY_INTERFACE" .ENV
"Server Name: " TYPE "SERVER_NAME" .ENV
"PATH Name: " TYPE "PATH" .ENV

\ --------- push the scripts postlude --------------
"</PRE>
</BODY>
</HTML>
" TYPE
---------8<----------------8<--------------
 
A

Albert van der Horst

I am trying to do some web scripting in Forth
This is a transcript of the perl
example from O'Reilly (Gundavaram) CGI-programming pg. 17.

With the multiple line strings and the occasional
auxiliary word, it looks neater than perl IMO.

However, no environment variables can be accessed from the
script apparently. The corresponding perl script has no
such problems. (Environment available in an associative
array %ENV ).
What is going on here?

I goofed. Apparently the implementation of ENV is broken.

With a redefinition of ENV (a ciforth specific dirty
hot patch) the script works:

\ Mysterious hot patch of ENV
: ENV' OLD: ENV 2 CELLS + ;
'ENV' 'ENV 3 CELLS MOVE

No discrimination agains Forth here.

<Script SNIPPED, see previous post>

Groetjes Albert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top