Listing of program rxmgage.cgi

#! /usr/bin/regina
/*   A rexxlet that compute a mortgage payment           */
/* At Entry : args = Loan_amount interest_rate duration  */
/* Returns  : none                                       */
/* Does     : evaluates and displays the monthly payment */
/*            as a GIF file                              */
/*-------------------------------------------------------*/

call setdll                      /* loads HHNS functions */


parse arg aaa                /* receives and checks args */
if pos(',', aaa)  > 0 
then parse var aaa C ',' T ',' N /* args like '100,2,3'  */
else parse var aaa C  T N        /* args like '100 2 3'  */




/*----        apply the Bernouilly formula     ---------*/
t = t/1200                 /* monthly rate              */
n = n*12                   /* duration in monthes       */
w = (1+t)**n               /* work variable             */
r = c*t*w /(w - 1)         /* monthly payment           */

t = strip(format(r, 8, 2)) /* with 2 decimal digits     */
l = length(t)              /* result's length           */

/*--- 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/           ---*/

dx = 8;  dy = 16;                       /* arbitrary Large font 8x16 */
r = 0; g = 255; z = 0;                  /* arbitrary green bgcoclor  */
f = "/tmp/rxmgage"d2x(getpid())".tmp"        /* the fly script name  */
call lineout f, "new"                        /* 1st FLY directive    */
call lineout f, "size" 4+dx * l","4+dy       /* Img size : we add 4  */
call lineout f, "fill 0,0,"r","g","z         /* Img BGcolor          */
call lineout f, "string 0,0,0,2,2,large,"t  /* the result string    */
call lineout f, "end"                        /* end of script        */
call lineout f                               /* Close the file       */

/*--- fill the result header and call Martin's FLY ---------------*/

say "Content-type: image/gif"
say
"/usr/local/bin/fly -i" f "2>/dev/null"

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

"rm -f" f 
return 0
Back   Home