home *** CD-ROM | disk | FTP | other *** search
/ The AGA Experience 2 / agavol2.iso / software / utilities / comms / html-heaven / arexx / html-se.rexx < prev    next >
OS/2 REXX Batch file  |  1996-01-08  |  2KB  |  53 lines

  1. /* HTML-Helper Arexx script for SAS-C's SE (Stream Editor)
  2.  * Ver      : 1.0 (7th January 1996)
  3.  * Copyright: Paul Kolenbrander (InterNet: paul@serena.iaehv.nl)
  4.  * Function : Pass on the HTML commands from HTML-Helper to SE.
  5.  * Input    : HTMLCMD - The HTML command to be inserted.
  6. */
  7.  
  8. OPTIONS RESULTS                                /* enable return codes      */
  9. PARSE ARG MYCMD HTMLCMD
  10. HTMLCMD = SUBSTR(HTMLCMD,2, LENGTH(HTMLCMD)-1) /* strip leading space      */
  11.  
  12. HTMLCMD = SUBSTR(HTMLCMD,2, LENGTH(HTMLCMD)-2) /* strip leading/trailing " */
  13.  
  14. posit=1                                        /* replace all '"' by '\"'  */
  15. NEWSTRING=""                                   /* as SE eats the '"'. :-(  */ 
  16. max=LENGTH(HTMLCMD)
  17. DO UNTIL posit = max
  18.    IF SUBSTR(HTMLCMD,posit,1) = '"' THEN
  19.       NEWSTRING = NEWSTRING || '\'
  20.    NEWSTRING = NEWSTRING || SUBSTR(HTMLCMD,posit,1)
  21.    posit=posit+1
  22. END  
  23. NEWSTRING = NEWSTRING || SUBSTR(HTMLCMD,LENGTH(HTMLCMD),1)
  24. HTMLCMD=NEWSTRING
  25.  
  26. address 'SC_SE'                                /* SE's ARexx port          */ 
  27.  
  28. IF POS('><',HTMLCMD) ~= 0 THEN DO              /* Is it a split command?   */
  29.                                                /* If yes, then....         */
  30.    'BM "E"'                                    /* Get Block end position   */
  31.    options results
  32.    'GL'                                        /* get the line number      */
  33.    end = result
  34.    'LL "'|| end ||'\n"'                        /* Move to end of block     */
  35.    'NL'
  36.    'BL'
  37.    CMD2 = right(HTMLCMD,(LENGTH(HTMLCMD)-(LASTPOS('<',HTMLCMD))+1))
  38.    'IL' CMD2                                   /* insert the back tag      */
  39.  
  40.    'BM "B"'                                    /* Get Block start position */
  41.    options results
  42.    'GL'                                        /* get the line number      */
  43.    begin = result
  44.    'LL "'|| begin ||'\n"'                      /* Move to start of block   */
  45.    CMD1 = substr(HTMLCMD,1,(LENGTH(HTMLCMD)-LENGTH(CMD2)))
  46.    'BL'
  47.    'IL' CMD1                                   /* insert the front tag     */
  48. END
  49. ELSE   
  50. 'IL' HTMLCMD                                   /* Insert at current pos.   */
  51.  
  52. EXIT                                           /* And exit the script.     */
  53.