home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxdlg11.zip / loop3.cmd < prev    next >
OS/2 REXX Batch file  |  1995-03-01  |  5KB  |  149 lines

  1. /* An example of a multiple windows. It creates a Main Window with a Push button
  2.     Group in it.  Whenever one of the buttons are pushed, this causes RXDLG to
  3.     return (ie, the Group has its END flag set).  I then open a window appropriate
  4.     to that button (ie, the window title becomes the string "Window XXX" where
  5.     XXX is the selected button number.    Of course, if that window is already
  6.     open, then I don't open it again. In that case, I close the window.
  7.     Note that my message loop has to take into account all of those possibly
  8.     open windows by checking RXWIND for that. Oh yeah, the Groups that we put
  9.     into the Child Dialogs is really trivial. Each window just gets 1 RESULT
  10.     Button Group with an OK in it.
  11. */
  12.  
  13. /* Trap ERROR and FAILURE */
  14. SIGNAL ON ERROR
  15. SIGNAL ON FAILURE
  16.  
  17. /* ================ Create "Main Window" dialog =============== */
  18. /* First Group is PUSH */
  19. RXTYPE.1 = 'PUSH'
  20.  
  21. /* Use of a control in this group causes RXDLG to return */
  22. RXFLAGS.1 = 'END'
  23.  
  24. /* Labels for each button, and Groupbox */
  25. RXLABEL.1 = 'One|Two|Three|Four|Windows'
  26.  
  27. /* TotalControls, ControlsPerLine, WidthOfControls */
  28. RXINFO.1 = '4 2 0'
  29.  
  30. /* Default choice for PushButton is nothing */
  31. RXVAL.1 = ''
  32.  
  33. /* Position */
  34. RXX.1 = 16
  35. RXY.1 = 10
  36.  
  37. RXWIN.0 = ' '
  38.  
  39. /* NOCLOSE since we'll close the window ourselves */
  40. RXDLG 1 '"Main Window"' 'RXWIN.0' 'NOCLOSE'
  41.  
  42. /* Initialize the Dimensions strings for the 4 child windows. Rexx Dailog
  43.  automatically updates these whenever the dialog is closed */
  44. RXWIN.1 = '110 60 60 60'
  45. RXWIN.2 = '110 60 70 70'
  46. RXWIN.3 = '110 60 90 90'
  47. RXWIN.4 = '110 60 110 110'
  48.  
  49. /* ============= Message loop on the dialog windows ============ */
  50. more:
  51.    /* Do user interaction. We go to sleep until RXDLG returns */
  52.    RXDLG
  53.  
  54.    /* Did user press ESC or click on the CLOSE ICON? */
  55.    IF RXID < 0 THEN DO
  56.  
  57.       /* If the Main Window, then close down our app. All windows and devices
  58.      that we opened are automatically closed down */
  59.       IF RXWIND = 'Main Window' THEN EXIT
  60.  
  61.    END
  62.  
  63.    /* User didn't abort */
  64.  
  65.    ELSE SELECT
  66.        /* ================ Main Window ================= */
  67.        WHEN RXWIND = "Main Window" THEN DO
  68.        /* Make the Child Dialog window title */
  69.        title = 'Window '||RXVAL.1
  70.  
  71.        /* Check if this window is already open */
  72.        RXQUERY '"'title'"'
  73.  
  74.        /* If the window is open, close it */
  75.        IF RC = 1 THEN RXDLG '"'title'"' 4
  76.  
  77.        /* Otherwise, open it */
  78.        ELSE DO
  79.            /* First Group is RESULT */
  80.            RXTYPE.1 = 'RESULT'
  81.  
  82.            /* Default */
  83.            RXFLAGS.1 = ' '
  84.  
  85.            /* No Groupbox */
  86.            RXLABEL.1 = ' '
  87.  
  88.            /* OK button */
  89.            RXINFO.1 = '2'
  90.  
  91.            /* Position */
  92.            RXX.1 = 7
  93.            RXY.1 = 6
  94.  
  95.         /* Use a stem variable for the Dimensions string, where
  96.            the stem is the window #. That way, each window has its own
  97.            dimensions string */
  98.         name = 'RXWIN.'||RXVAL.1
  99.  
  100.         /* Present child */
  101.         RXDLG 1 '"'title'"' name 'NOCLOSE|RESULT'
  102.        END
  103.        END
  104.  
  105.        /* =============== "Window 1" Dialog ================ */
  106.        WHEN RXWIND = "Window 1" THEN DO
  107.        RXSAY RXWIND
  108.        END
  109.  
  110.        /* =============== "Window 2" Dialog ================ */
  111.        WHEN RXWIND = "Window 2" THEN DO
  112.        RXSAY RXWIND
  113.        END
  114.  
  115.        /* =============== "Window 3" Dialog ================ */
  116.        WHEN RXWIND = "Window 3" THEN DO
  117.        RXSAY RXWIND
  118.        END
  119.  
  120.        /* =============== "Window 4" Dialog ================ */
  121.        WHEN RXWIND = "Window 4" THEN DO
  122.        RXSAY RXWIND
  123.        END
  124.  
  125.    END
  126.  
  127.    /* Close the Window if it's not the Main Window. Note that we
  128.        wouldn't need this if we omitted the NOCLOSE Flag on our
  129.        Child Dialogs */
  130.    IF RXWIND \= "Main Window" THEN RXDLG '"'RXWIND'"' 4
  131.  
  132. /* Do another message loop */
  133. SIGNAL more
  134.  
  135. /* =================================================== */
  136.  
  137. FAILURE:
  138.     /* NOTE: the variable RC contains the returned error message (not a number,
  139.     unless we use RXERR to set up Rexx Dialog to return error numbers instead).
  140.     Because we used the default severity level, Rexx Dialog has already displayed
  141.     this error message to the enduser */
  142.     EXIT
  143. ERROR:
  144.     /* NOTE: the variable RC contains the returned error message (not a number,
  145.     unless we use RXERR to set up Rexx Dialog to return error numbers instead).
  146.     Because we used the default severity level, Rexx Dialog has already displayed
  147.     this error message to the enduser */
  148.     EXIT
  149.