Listing of program rxcount.cgi

#!/usr/bin/regina
/*   A rexxlet that displays a number as an Image       */
/* At Entry : args = number    style                    */
/* Returns  : none                                      */
/* Does     : display the number as a GIF file          */
/* Translated from Matt.Wright's perl script            */
/*              www.worldwidemart.com/scripts/          */
/*------------------------------------------------------*/

numeric digits 12

/*--------- process args -------------------------*/
parse arg count style
len = length(strip(count));
if style = "" then style = "default" /* default style */

/* this is where the digits images are : a subdir per style */
/*- in each subdir, there is a 'dim.txt' file              -*/
/*- which gives the size (x, y) of any digit               -*/

digit_dir = "/home/www/html/imglib/digits/"style;
w = linein(digit_dir"/dim.txt")      /*-- read dim file    -*/
parse var w width height .           /*-- get x, y in pix. -*/

/* get each digit in a table (t.)  */
do i = len to 1 by -1
   t.i = substr(count, i, 1);
end

/* set the Height and Width of the Result    */
img_width  = width * len
img_height = height

/*--- Prepare a script file for 'FLY', a great shareware program ---*/
/*--- that builds gif images 'on the fly', ex-nihilo ...         ---*/
/*--- See Martin Gleeson http://www.unimelb.edu.au/fly           ---*/

fly_temp = "/tmp/fly"d2x(getpid())".tmp"       /* temp. script name */
call lineout fly_temp, "new";
call lineout fly_temp, "size" img_width","img_height;

/*--- copy each digit image commands in the fly script -------------*/

insert_width = 0
insert_height = 100
do i = 1 to len
   call lineout fly_temp, "copy" insert_width","insert_height || ,
                          ",-1,-1,-1,-1,"digit_dir"/"t.i".gif"
   insert_width = insert_width + width 
end

/*- CLose script, then fill the result header and call Martin's FLY */

call lineout fly_temp;
say "Content-type: image/gif"
say
"/usr/local/bin/fly -q -i" fly_temp  "2>/dev/null"

/*----------- All done : Housekeeping and returns ... --------------*/

'rm -f' fly_temp;
return 0
Back   Home