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

  1. /* This creates a Main Window, with 1 PUSH Group with 1 button labeled
  2.     "Time-out". When the user presses that button, we create a Child Dialog
  3.     just for the purpose of counting down a time-out. The Child contains a
  4.    TEXT Group with 1 blank line of text, is MODAL, and is hidden. The point of
  5.    this is so that we can do a timeout without the user being able to interact
  6.    during that timeout, as well as not seeing the time-out window. We start up
  7.    the time-out in the hidden window, and pass that window to RXDLG, doing an
  8.    Operation of 0. So, when RXDLG returns, the window has timed out.
  9. */
  10.  
  11. /* Trap ERROR and FAILURE */
  12. SIGNAL ON ERROR
  13. SIGNAL ON FAILURE
  14.  
  15. /* =============== Create "Main Window" ================= */
  16. /* First Group is PUSH */
  17. RXTYPE.1 = 'PUSH'
  18.  
  19. /* Use of a control in this group causes RXDLG to return. Also let RXDLG
  20.     label the controls with numbers */
  21. RXFLAGS.1 = 'END'
  22.  
  23. /* Label, no groupbox */
  24. RXLABEL.1 = 'Time-Out'
  25.  
  26. /* TotalControls, ControlsPerLine, WidthOfControls */
  27. RXINFO.1 = '1 1 0'
  28.  
  29. /* */
  30. RXVAL.1 = ''
  31.  
  32. /* Position */
  33. RXX.1 = 7
  34. RXY.1 = 6
  35.  
  36. /* Use another TEXT Group to display the elapsed timeout */
  37. RXTYPE.2 = 'TEXT'
  38.  
  39. /* Default */
  40. RXFLAGS.2 = ' '
  41.  
  42. /* Text lines */
  43. RXLABEL.2 = ' '
  44.  
  45. /* TotalPhrases, PhrasesPerLine, WidthOfPhrase, BetweenPhrases. Note that
  46.  we deliberately set WidthOfPhrase non-0 to allow enough width to accomodate
  47.  a variety of phrases */
  48. RXINFO.2 = '1 1 90 0'
  49.  
  50. /* Position */
  51. RXX.2 = 10
  52. RXY.2 = 40
  53.  
  54. /* Default size and position (also gives us sizing and max button) */
  55. RXWIN1 = ''
  56. RXDLG 2 '"Main Window"' 'RXWIN1' 'NOCLOSE'
  57.  
  58. more:
  59. /* Do user interaction */
  60. RXDLG
  61.  
  62. /* We only have 1 window (without KEYS or RESULT flag), with one pushbutton,
  63.     so it's either the CLOSE ICON or that button that caused RXDLG to return */
  64.  
  65. /* Did user click on the CLOSE ICON? */
  66. IF RXID < 0 THEN EXIT
  67.  
  68. /* ================== Create "Child 1" dialog ================== */
  69. /* First Group is TEXT */
  70. RXTYPE.1 = 'TEXT'
  71.  
  72. /* Default */
  73. RXFLAGS.1 = ' '
  74.  
  75. /* Empty Label, no Groupbox */
  76. RXLABEL.1 = '|'
  77.  
  78. /* TotalControls, ControlsPerLine, WidthOfControls */
  79. RXINFO.1 = '1 1 0'
  80.  
  81. /* Default choice for PushButton is nothing */
  82. RXVAL.1 = ''
  83.  
  84. /* Position */
  85. RXX.1 = 1
  86. RXY.1 = 1
  87.  
  88. RXWIN2 = '1 1 0 0'
  89.  
  90. /* Set MODAL */
  91. RXDLG 1 '"Child 1"' 'RXWIN2' 'MODAL'
  92. /* ========================================================= */
  93.  
  94. /* Hide the child window. The window is only 1 by 1 pixel, so it's pretty hard
  95.  to see down there in lower left corner of Main, but... */
  96. RXSET '"Child 1"' 'HIDE'
  97.  
  98. /* Setup a timeout (in Child 1) for 5000 milliseconds (ie, 5 seconds) */
  99. RXSET '"Child 1"' 'TIME' 5000
  100.  
  101. /* Print "Timing Out..." in the main window */
  102. RXSET '""' 2 1 'VAL' 'Timing Out...'
  103.  
  104. /* Do the timeout. Specify "Child 1" and because it's hidden and MODAL,
  105.    user can't interact with any windows. Because we didn't specify
  106.    NOCLOSE, this window is closed at the end of the time-out */
  107. RXDLG '"Child 1"'
  108.  
  109. /* Print "All Done!" in the main window */
  110. RXSET '""' 2 1 'VAL' 'All Done!'
  111.  
  112. SIGNAL more
  113.  
  114. /* ========================== Done ========================== */
  115.  
  116. FAILURE:
  117.     /* NOTE: the variable RC contains the returned error message (not a number,
  118.     unless we use RXERR to set up Rexx Dialog to return error numbers instead).
  119.     Because we used the default severity level, Rexx Dialog has already displayed
  120.     this error message to the enduser */
  121.     EXIT
  122. ERROR:
  123.     /* NOTE: the variable RC contains the returned error message (not a number,
  124.     unless we use RXERR to set up Rexx Dialog to return error numbers instead).
  125.     Because we used the default severity level, Rexx Dialog has already displayed
  126.     this error message to the enduser */
  127.     EXIT
  128.