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

  1. /* An example of setting a timeout for a window */
  2.  
  3. /* Trap ERROR and FAILURE */
  4. SIGNAL ON ERROR
  5. SIGNAL ON FAILURE
  6.  
  7.  
  8. /* ====================== 'Main Window' ======================= */
  9. /* First Group is TEXT */
  10. RXTYPE.1 = 'TEXT'
  11.  
  12. /* Default */
  13. RXFLAGS.1 = ' '
  14.  
  15. /* Text lines */
  16. RXLABEL.1 = "Example of a timeout. Here's the elapsed seconds:"
  17.  
  18. /* TotalPhrases, PhrasesPerLine, WidthOfPhrase, BetweenPhrases */
  19. RXINFO.1 = '1 1 0 0'
  20.  
  21. /* Position */
  22. RXX.1 = 10
  23. RXY.1 = 30
  24.  
  25. /* Use another TEXT Group to display the elapsed timeout */
  26. RXTYPE.2 = 'TEXT'
  27.  
  28. /* Default */
  29. RXFLAGS.2 = ' '
  30.  
  31. /* Text lines */
  32. RXLABEL.2 = '0'
  33.  
  34. /* TotalPhrases, PhrasesPerLine, WidthOfPhrase, BetweenPhrases. Note that
  35.  we deliberately set WidthOfPhrase non-0 to allow enough width to accomodate
  36.  a range of text digits */
  37. RXINFO.2 = '1 1 64 0'
  38.  
  39. /* Position */
  40. RXX.2 = 10
  41. RXY.2 = 10
  42.  
  43. /* Default size and position (also gives us sizing and max button) */
  44. RXWINMAIN = ' '
  45. RXDLG 2 '"Main Window"' 'RXWINMAIN' 'NOCLOSE|RESULT'
  46.  
  47. /* Start with 0 seconds */
  48. Seconds=0
  49.  
  50. /* Setup a timeout (in Main Window) for 1000 milliseconds (ie, every second) */
  51. RXSET '""' 'TIME' 1000
  52.  
  53. more:
  54.    /* Do user interaction (and also timeout). We go to sleep while user
  55.       manipulates the window and timer counts down, until such time as the
  56.       user presses ESC or ENTER if the window's RESULT Flag is set, or tries
  57.       to close a dialog using its CLOSE ICON, or uses a RESULT Group, or
  58.       uses some Group with its END Flag set, or presses a key if the window's
  59.       KEYS Flag is set, or the timer times out */
  60.    RXDLG  /* NOTE: No window title means "use Main Window". No operation
  61.            specified means an operation of 0 (ie, PROCESS) */
  62.  
  63.    /* RXWIND now specifies which window woke us up. (The window is still
  64.       there because we specified NOCLOSE). NOTE: All of the RXVAL and any
  65.      LIST/DROP BOX stem variables, RXID, RXSUBID, and RXWIND variables and the
  66.       Dimensions string for that window) have been setup according to the
  67.       state of this window when RXDLG returned */
  68.  
  69.    /* Did user press ESC or click on the CLOSE ICON? Note that we haven't set
  70.       the KEYS flag of any window, so we don't need to check for particular
  71.       negative values of RXID because the only 2 we ever receive here are
  72.       for the ESC key and CLOSE ICON */
  73.    IF RXID < 0 THEN EXIT
  74.  
  75.    /* If user didn't abort, then check if this is a timeout (ie, both RXID and
  76.       RXSUBID are 0) */
  77.    IF RXID+RXSUBID = 0 THEN DO
  78.        Seconds = Seconds+1
  79.        RXSET '"Main Window"' 2 1 'VAL' Seconds
  80.    END
  81.  
  82.    /* NOTE: We have no RESULT Group nor any Groups with the END Flag set,
  83.       so there's no need to further check for RXID being anything but -1 or 0,
  84.       and therefore what we must have here is the ENTER key (ie, RXID=0,
  85.       RXSUBID=10) */
  86.    ELSE DO
  87.       /* Throw up a RXSAY message. This will cause us to stop here until the
  88.      user dismisses the box. Note that during this time, our display isn't
  89.      updating because we need to be sleeping in RXDLG in order for any
  90.      timeouts to be received */
  91.       RXSAY 'ENTER pressed.'
  92.    END
  93.  
  94. /* Do another message loop */
  95. SIGNAL more
  96.  
  97. /* ========================== Done ========================== */
  98.  
  99. FAILURE:
  100.     /* NOTE: the variable RC contains the returned error message (not a number,
  101.     unless we use RXERR to set up Rexx Dialog to return error numbers instead).
  102.     Because we used the default severity level, Rexx Dialog has already displayed
  103.     this error message to the enduser */
  104.     EXIT
  105. ERROR:
  106.     /* NOTE: the variable RC contains the returned error message (not a number,
  107.     unless we use RXERR to set up Rexx Dialog to return error numbers instead).
  108.     Because we used the default severity level, Rexx Dialog has already displayed
  109.     this error message to the enduser */
  110.     EXIT
  111.