/* HTML-Helper Arexx script for Annotate
 * Ver      : 1.0 (27th April 1995)
 * Author   : paul Kolenbrander (paul@serena.iaehv.nl)
 * Function : Pass on the HTML commands from HTML-Helper to Annotate.
 * Input    : HTMLCMD - The HTML command to be inserted.
 * Caveat   : you'll need to load the document into your browser manually
 *            the first time. As I can't find a commmand to get the filename
 *            from Annotate, I can only tell the browser to do a reload.  
*/

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

ADDRESS 'Annotate_Rexx'                       /* Default, edit if needed */

HTMLCMD = SUBSTR(HTMLCMD,2, LENGTH(HTMLCMD)-2) /* strip leading/trailing " */

IF POS('><',HTMLCMD) ~= 0 THEN DO             /* Is it a split command?  */
                                              /* If yes, then....        */
   GET SEL_SIZE                               /* Check if block selected */
   IF result ~= "RESULT" THEN DO              /* Block selected          */
      PARSE VAR result beginx beginy endx endy
      CMD2 = right(HTMLCMD,(LENGTH(HTMLCMD)-(LASTPOS('<',HTMLCMD))+1))
      CMD1 = substr(HTMLCMD,1,(LENGTH(HTMLCMD)-LENGTH(CMD2)))
      MOVE_CURSOR ABS endx endy
      INSERT STRING CMD2                      /* Insert at block end     */
      MOVE_CURSOR ABS beginx beginy
      INSERT STRING CMD1                      /* Insert at block begin   */
   END
   ELSE
      INSERT STRING HTMLCMD                   /* Insert at current pos   */
   END
ELSE
   INSERT STRING HTMLCMD                      /* Insert at current pos   */

IF MYCMD = 'SAVE' THEN DO                     /* I can't find a command  */
   DOMENU SAVE                                /* to make Annotate part   */
   ADDRESS COMMAND 'rx S:HTMLVIEW.rexx'       /* with the filename.      */
END

EXIT                                          /* And exit the script.    */

