Wow! New CGIs

Richard Gaskin ambassador at fourthworld.com
Fri Apr 17 00:03:06 EDT 2009


J. Landman Gay wrote:

> This is too cool. I have an old Rev CGI example on my web site. It just 
> picks a random line from a list of image files and displays the image in 
> an iframe. It requires about 25 lines of script and two additional text 
> files to do its work. The CGI loads an html template from a file, loads 
> and reads a list of images from another text file, replaces markers in 
> the template with a random line from the image list, and sends the whole 
> business back to the browser. Thirty lines of script, two text files, 
> and of course a folder of images -- and useless if the user's browser 
> doesn't support iframes.
> 
> Now I can do it with one line of Rev script placed directly inside the 
> web page itself. All I had to do was embed this in the page:
> 
> <?rev
> put "<img src="&quote&"cgiphotos/" & any line of url 
> ("file:cgiphotos.txt") &quote& ">"
> ?>
> 
> Is that cool or what? I'm *very* excited about all this.

The new server package is very cool, esp. the live debugging, but FWIW 
you can do that script with the old CGI with just two lines, one in the 
CGI and one in a web page template:


-- cgi script:
put "Content-Type: text/plain" & cr & cr & \
     merge(template.txt) &cr&cr


-- template.txt:
This is an image: <img src=<?
return any line of url ("file:cgiphotos.txt")
?>>


The merge function is an underrated powerhouse.

--
  Richard Gaskin
  Fourth World
  Revolution training and consulting: http://www.fourthworld.com
  Webzine for Rev developers: http://www.revjournal.com



More information about the use-livecode mailing list