/************************************************************************/
/*                                                                      */
/*                        JumpNextNoReply.rexx                          */
/*                                                                      */
/* This script jumps to the next message written to you and which you   */
/* haven't replied (a NoReply message)                                  */
/*                                                                      */
/* Author: Mark de Jong                                                 */
/* Date  : 9 January 1994                                               */
/*                                                                      */
/* All rights reserved.                                                 */
/*                                                                      */
/* You are free to modify this script for your own purposes.            */
/*                                                                      */
/************************************************************************/

 options results                  /* get results from function          */
 address APRILREXX                /* port we talk to                    */

 arewein AREAMENU                 /* see where we are in April          */

 menu=0

 IF rc=0 THEN                     /* we are in AreaMenu                 */
   DO
      menu=1
      gotoarea NOREPLY NEXT       /* highlight the first area with      */

   END                            /* a NOREPLY flag.                    */

   gotoshowmsg                    /* go into this area (to showmsg)     */
                                  /* if we're already there, that's     */
                                  /* no problem.                        */

   setptratmsg                    /* get ptr of the message (private)   */
   ptruseflags NORMAL             /* set the ptr flags (NORMAL/ID/..)   */
   
   IF menu=1 THEN
     browseptr FIRST              /* browse to the first message        */
                                  /* only when we started in Areamenu   */

   rc=0                           /* reset the resultcode rc to 0       */


  DO WHILE rc=0

   DO WHILE rc=0                  /* do this as long there are msgs     */

    browseptr NEXT                /* browse one message ahead           */
    IF rc=0 THEN                  /* if there is a message, then...     */
     DO

      isptrflagset NOREPLY        /* check if the NOREPLY flag is set   */

      IF rc=0 THEN                /* if there is a NoReply message      */

        rc=9                      /* set rc=9 which means we break      */

      ELSE                        /* otherwise...                       */

        rc=0                      /* reset the resultcode. This is      */

     END
                                  /* needed to continue the loop.       */
   END


  IF rc=5 THEN                    /* ran out of messages                */
   DO

    gotoarea NOREPLY NEXT         /* go to next area with NoReply flag  */

   END

  IF rc=5 THEN                    /* if there are no more NoReply areas */
   DO

    'remark TEXT "Couldn''t find next NoReply message"'
    rc=9

   END

  IF rc=9 THEN BREAK              /* there is a NoReply message, so     */
                                  /* break out the while loop           */

 END

  setmsgatptr                     /* go to the message, the ptr is      */
                                  /* pointing at.                       */

 exit                             /* and finally exit                   */

