Guidance
指路人
g.yi.org
Software / Reginald / Examples / Loop3.rex

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
/* An example of a multiple windows. It creates a Main Window with a Push button
 * Group in it.  Whenever one of the buttons are pushed, this causes RXMSG to
 * return (ie, the Group has its REPORT flag set).  I then open a window appropriate
 * to that button (ie, the WindowTitle becomes the string "Window XXX", and the
 * WindowID is "WinXXX" where XXX the button number). Of course, if that window is
 * already open, then I don't open it again. In that case, I close the window.
 * Note that my message loop has to take into account all of those possibly
 * open windows by checking RXWIND for that. Oh yeah, the Groups that we put
 * into the Child Windows are really trivial. Each window just gets 1 RESULT
 * Button Group with an OK in it.
 */

ADDRESS null

/* Trap HALT and SYNTAX in any scripts we call which don't
 * trap HALT or SYNTAX themselves.
 */
OPTIONS 'TRAP'

/* Trap SYNTAX/ERROR/HALT, and ask for ERROR raising */
SIGNAL ON HALT
SIGNAL ON SYNTAX
SIGNAL ON ERROR
CALL RXERR('ERROR|DISPLAY')





/* ================ Create "Main Window" =============== */
/* First Group is PUSH */
rxtype.1 = 'PUSH'

/* Use of a control in this group causes RXMSG to return */
rxflags.1 = 'REPORT'

/* Labels for each button, and Groupbox */
rxlabel.1 = 'One|Two|Three|Four|Windows'

/* Default choice for PushButton is nothing */
rxval.1 = ''

/* ControlsPerLine, X Position, Y Position, Width=0 */
rxpos.1 = '2 16 20'

rx = ''

/* NOCLOSE since we'll close the window ourselves */
CALL RXCREATE('RX', 1, 'Main Window', 'NOCLOSE')

/* Initialize the Dimensions strings for the 4 child windows. REXX
 * Dialog automatically updates these whenever the window is closed
 */
win1 = ''
win2 = ''
win3 = ''
win4 = ''

/* ============= Message loop on the windows ============ */
more:
   /* Do user interaction. We go to sleep until RXMSG returns */
   CALL RXMSG()

   /* Did user press ESC or click on the CLOSE ICON of Main Window? If so, end script */
   IF rxid == '' & rxwind = 'RX' THEN SIGNAL HALT

   SELECT

      /* ================ Main Window ================= */
      WHEN rxwind = "RX" THEN DO
         /* Make the Child Window's title */
         id = 'WIN'||rxsubid

         /* Check if this window is already open */
         CALL RXQUERY(id, 'ACTIVE', 'openflag')

         /* If the window is open, close it */
         IF openflag THEN CALL RXMSG(id, 'END')

         /* Otherwise, open it */
         ELSE DO
            /* First Group is PUSH button with RESULT flag */
            CALL VALUE(id||type.1, 'PUSH')

            /* Default Flags */
            CALL VALUE(id||flags.1, 'RESULT')

            /* OK button, no groupbox */
            CALL VALUE(id||label.1, 'OK|')

            /* ControlsPerLine, X Position, Y Position */
            CALL VALUE(id||pos.1, '-1 7 6')

            /* Present child */
            CALL RXCREATE(id, 1, 'Window '||rxsubid, 'NOCLOSE|RESULT')
         END
      END

      /* =============== "Window 1" Window ================ */
      WHEN rxwind = "WIN1" THEN DO
         CALL RXSAY(rxwind)
      END

      /* =============== "Window 2" Window ================ */
      WHEN rxwind = "WIN2" THEN DO
         CALL RXSAY(rxwind)
      END

      /* =============== "Window 3" Window ================ */
      WHEN rxwind = "WIN3" THEN DO
         CALL RXSAY(rxwind)
      END

      /* =============== "Window 4" Window ================ */
      WHEN rxwind = "WIN4" THEN DO
         CALL RXSAY(rxwind)
      END

   END

   /* Close the Window if it's not the Main Window. Note that we
    * wouldn't need this if we omitted the NOCLOSE Flag on our
    * Child windows
    */
   IF rxwind \= "RX" THEN CALL RXMSG(rxwind, 'END')

/* Do another message loop */
SIGNAL more





/* ==================== Error Handling ====================== */
syntax:
    CALL RXSAY(CONDITION('D') || '0D0A0D0A'x || SOURCELINE(sigl),,'Error '||condition('E')||' at line '||sigl)

halt:
error:
    /* NOTE: CONDITION('D') fetches error message. CONDITION('E') fetches the
     * error number. SIGL is the line number where the error occurred.
     * Rexx Dialog has already displayed a message since we specified DISPLAY
     * option.
     */
    CALL RXMSG(,'END')
    EXIT
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2024-3-29  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2013-06-18 23:35:08