/* HTML-Helper Arexx script for BED (Black's Editor)
 * Ver      : 1.1 (7th January 1996)
 * Copyright: Paul Kolenbrander (InterNet: paul@serena.iaehv.nl)
 * Function : Pass on the HTML commands from HTML-Helper to BED.
 * Input    : HTMLCMD - The HTML command to be inserted.
*/

OPTIONS RESULTS                             /* enable return codes     */
PARSE ARG MYCMD HTMLCMD

HTMLCMD = SUBSTR(HTMLCMD,2, LENGTH(HTMLCMD)-1) /* strip leading space  */

ADDRESS 'BED_0'                             /* Default. Change if wish */

IF POS('><',HTMLCMD) ~= 0 THEN DO           /* Is it a split command?  */
                                            /* If yes, then....        */
   GetBlkInfo                               /* Check if there's a block*/
   PARSE VAR RESULT BlockActive . BlockRow BlockCol
   IF BlockActive = ON THEN DO              /* character block mode    */
                                            /* Split HTMLCMD into parts*/
      CMD2 = right(HTMLCMD,(LENGTH(HTMLCMD)-(LASTPOS('<',HTMLCMD))+1))
      CMD1 = substr(HTMLCMD,1,(LENGTH(HTMLCMD)-LENGTH(CMD2)))
      CMD1 = CMD1||'"'                      /* add a trailing "        */
      CMD2 = '"'||CMD2                      /* add a leading "         */
      GetCursorPos                          /* get cursor position     */
      PARSE VAR RESULT CurLine CurCol .
      Move CurLine CurCol                   /* Goto end of Block       */                                                     
      Insert CMD2                           /* Insert close at cursor. */

      Move BlockRow BlockCol                /* Goto start of Block     */
      Insert CMD1                           /* Insert open at cursor.  */
      END
      ELSE                                  /* no block mode           */
        Insert HTMLCMD                      /* insert at current pos.  */
   END
ELSE
   Insert HTMLCMD                           /* insert at current pos.  */
EXIT
