home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / gohttp.zip / DOINCL.CMD < prev    next >
OS/2 REXX Batch file  |  1995-07-04  |  3KB  |  58 lines

  1. /*  Mike Cowlishaw's Server-side includes parser, excerpted from GoRemote.80.   */
  2. /*  ...slightly modified by D.L. Meyer...            */
  3.  
  4. /*  Upon call from GoHTTP.v20, the current directory will have been changed     */
  5. /*   to the REXX script directory.   Subsequent calls to scripts located there     */
  6. /*   need not change directory...                */
  7.  
  8. /* ---------------------------------------------------------------- */
  9. /* DOINCL: process a block of html for server-side includes   */
  10. /* ---------------------------------------------------------------- */
  11. /* ARG(1) is block of data                                 */
  12. /*DoIncl: procedure        */
  13.   parse arg data
  14.   out=''                                     /* result */
  15.   do forever
  16.     parse var data pre '{' expr '}' data     /* find expression */
  17.     out=out''pre                             /* pre-stuff */
  18.     if expr='' then if data='' then leave    /* no more '{' */
  19.     out=out''eval(expr, '')             /* add evaluation */
  20.     end
  21.   return out                                  /* [called as function] */
  22.  
  23. /* ---------------------------------------------------------------- */
  24. /* EVAL: return an expression evaluation [protected]                */
  25. /* ---------------------------------------------------------------- */
  26. /* ARG(1) is expression to evaluate                                 */
  27. /* ARG(2) is passed from PAGE, usually an arbitrary text message    */
  28. /* An expression starting with '?' is a direct EXTRACT, special-    */
  29. /* cased for simplicity.  ({?foo} == {extract(foo)})                */
  30. eval: procedure                         /* no variables visible */
  31.   if left(strip(arg(1)),1)='?' then return extract(substr(strip(arg(1)),2))
  32.   /* arbitrary expression expected -- assume CRLF and tabs are whitespace */
  33.   signal on syntax name evaloops                       /* handle errors */
  34.   interpret 'result='translate(arg(1),' ','0d0a09'x)   /* evaluate */
  35.   return result                                        /* done */
  36.  
  37. evaloops: return '[?]'
  38.  
  39. /* ---------------------------------------------------------------- */
  40. /* IF: select string based on ARG(1)                                */
  41. /* ---------------------------------------------------------------- */
  42. /* Rather like C's "?" operation */
  43. if: if arg(1) then return arg(2); else return arg(3)
  44.  
  45. /* ---------------------------------------------------------------- */
  46. /* QFLAG:  return 'checked' for a flag that's ON,  null otherwise   */
  47. /* QFLAGN: return 'checked' for a flag that's OFF, null otherwise   */
  48. /* ---------------------------------------------------------------- */
  49. qflag:  if extract(arg(1))='ON'  then return 'checked'; else return ''
  50. qflagn: if extract(arg(1))='OFF' then return 'checked'; else return ''
  51.  
  52. /* ---------------------------------------------------------------- */
  53. /* GMTWARN: return warning if GMT unavailable, null otherwise       */
  54. /* ---------------------------------------------------------------- */
  55. gmtwarn: if extract('GMTSET')='ON' then return ''
  56. return '[TZ was not set - GMT is <strong>not</strong> available]'
  57.  
  58.