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

  1. /* An example of a Modal Design. It creates a Main Window, and then a
  2.    Child Dialog. Since the Child is MODAL and we specify that window to
  3.    RXDLG when doing an Operation with user interaction, then the user
  4.    is limited to interacting with that window until RXDLG returns.
  5. */
  6.  
  7. /* Trap ERROR and FAILURE */
  8. SIGNAL ON ERROR
  9. SIGNAL ON FAILURE
  10.  
  11. /* =============== Create "Main Window" ================= */
  12. /* First Group is RADIO */
  13. RXTYPE.1 = 'RADIO'
  14.  
  15. /* Use of a control in this group causes RXDLG to return. Also let RXDLG
  16.     label the controls with numbers */
  17. RXFLAGS.1 = 'END|NUMBERED'
  18.  
  19. /* Only need to specify Groupbox (or null string if none) because of NUMBERED */
  20. RXLABEL.1 = 'Pick one'
  21.  
  22. /* TotalControls, ControlsPerLine, WidthOfControls */
  23. RXINFO.1 = '16 4 0'
  24.  
  25. /* Initially select button 1 */
  26. RXVAL.1 = '1'
  27.  
  28. /* Position */
  29. RXX.1 = 7
  30. RXY.1 = 6
  31.  
  32. /* Default size and position (also gives us sizing and max button) */
  33. RXWIN1 = ''
  34.  
  35. RXDLG 1 '"Main Window"' 'RXWIN1' 'RESULT'
  36.  
  37.  
  38.  
  39.  
  40. /* ================== Create "Child 1" dialog ================== */
  41. /* First Group is PUSH */
  42. RXTYPE.1 = 'PUSH'
  43.  
  44. /* Use of a control in this group causes RXDLG to return */
  45. RXFLAGS.1 = 'END'
  46.  
  47. /* Labels for each button, and Groupbox */
  48. RXLABEL.1 = 'One|Two|Three|Four|Choices'
  49.  
  50. /* TotalControls, ControlsPerLine, WidthOfControls */
  51. RXINFO.1 = '4 2 0'
  52.  
  53. /* Default choice for PushButton is nothing */
  54. RXVAL.1 = ''
  55.  
  56. /* Position */
  57. RXX.1 = 7
  58. RXY.1 = 6
  59.  
  60. RXWIN2 = '190 108 8 8'
  61.  
  62. /* Set MODAL, so when we wake up, it will be this window that caused
  63.    RXDLG to return (ie, Main window will not have been allowed to be used) */
  64. RXDLG 1 '"Child 1"' 'RXWIN2' 'MODAL|RESULT'
  65.  
  66. /* Do user interaction. Because we specified a window, and its MODAL,
  67.    the user is limited to interacting with this window */
  68. RXDLG '"Child 1"' /* No Operation means Operation 0 */
  69.  
  70. /* RXWIND now specifies which window woke us up. Because we specified MODAL,
  71.    then it must have been "Child 1" which caused RXDLG to return. The window
  72.    is no longer there because we didn't specify NOCLOSE for Child 1 */
  73. RXSAY '"'RXWIND'" woke us up.'
  74.  
  75. /* Did user press ESC or click on the CLOSE ICON? Note that we haven't set
  76.     the KEYS flag of any window, so we don't need to check for particular
  77.     negative values of RXID because the only 2 we ever receive here are
  78.     for the ESC key and CLOSE ICON */
  79. IF RXID < 0 THEN DO
  80.    RXSAY '"'RXWIND'" aborted.'
  81. END
  82.  
  83. /* Did user press the ENTER key while the window had the focus?
  84.    Note that we haven't setup a timeout, nor set the KEYS flag
  85.    of any window, so we don't need to check RXSUBID. It's always
  86.    going to be 10 (ie, ENTER) here if RXID is 0 */
  87. IF RXID = 0 THEN DO
  88.    RXSAY 'Pressed ENTER on "'RXWIND'".'
  89. END
  90.  
  91. /* If RXID is greater than 0, then this is the Group #, and RXSUBID is the
  92.    Control # (within that group), of the control that caused RXDLG to
  93.    return. NOTE: The first control within the first group (for this dialog) has a
  94.   Group # and Control # of 1 */
  95. IF RXID > 0 THEN DO
  96.     RXSAY 'Group #'RXID', Control #'RXSUBID' ended "'RXWIND'" dialog.'
  97. END
  98.  
  99. /* At this point, we could call RXDLG with no parameters to let the user
  100.    interact with Main Window. But let's just end */
  101. EXIT
  102.  
  103.  
  104. /* ========================== Done ========================== */
  105.  
  106. FAILURE:
  107.     /* NOTE: the variable RC contains the returned error message (not a number,
  108.     unless we use RXERR to set up Rexx Dialog to return error numbers instead).
  109.     Because we used the default severity level, Rexx Dialog has already displayed
  110.     this error message to the enduser */
  111.     EXIT
  112. ERROR:
  113.     /* NOTE: the variable RC contains the returned error message (not a number,
  114.     unless we use RXERR to set up Rexx Dialog to return error numbers instead).
  115.     Because we used the default severity level, Rexx Dialog has already displayed
  116.     this error message to the enduser */
  117.     EXIT
  118.