home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxdlg11.zip / errors.cmd < prev    next >
OS/2 REXX Batch file  |  1994-12-29  |  3KB  |  78 lines

  1. /* */
  2. CALL ON FAILURE
  3. CALL ON ERROR
  4.  
  5. /* Cause an error with Rexx Dialog's RXDLG command. (We're trying to perform
  6.     an END operation upon a dialog that doesn't exist. We should get the
  7.     "Can't find Rexx Dialog' error message returned). We get an error string
  8.     back, and also Rexx Dialog automatically displays a message box, because
  9.     those are the defaults */
  10. RXDLG 'my window'
  11. RXSAY 'RC = 'RC
  12.  
  13. /* Do the same error, but this time ask to be returned an error number. We
  14.     haven't changed the default severity level, so Rexx Dialog is still going
  15.     to display that message box */
  16. RXERR 'NUM'
  17. RXDLG 'my window'
  18. RXSAY 'RC = 'RC
  19.  
  20. /* Do the same error, but this time change the severity level to 0. We're
  21.     going to get the error message returned, but Rexx Dialog isn't going
  22.     to display that message box */
  23. RXERR '0'
  24. RXDLG 'my window'
  25. RXSAY 'RC = 'RC
  26.  
  27. /* Do the same error, but this time change the severity level to 0 and ask
  28.     for an error number return. Again, Rexx Dialog isn't going to display
  29.     that message box */
  30. RXERR '0|NUM'
  31. RXDLG 'my window'
  32. RXSAY 'RC = 'RC
  33.  
  34. /* Let's ask for FULL error messages. When the error occurs on this call to
  35.     RXDLG, Rexx Dialog will post a REXX INTERPRETER ERROR message box
  36.     (actually two; one containing the line # where the error occurred, and
  37.     your REXX statement, which is "RXDLG 'my window'" for this example, and
  38.     then a second message box containing the error message returned by Rexx
  39.     Dialog which will be 'Can't find Rexx Dialog' for this example. Note: We
  40.     CALL ON FAILURE when we have 'FULL' on. The preceding errors with
  41.     RXDLG caused the CALL ON ERROR. The RC we get back is the "Can't
  42.     find Rexx Dialog" error message, because we didn't ask for NUM. */
  43. RXERR 'FULL'
  44. RXDLG 'my window'
  45. RXSAY 'RC = 'RC
  46.  
  47. /* Same thing as above, but this time give me an error number back */
  48. RXERR 'FULL|NUM'
  49. RXDLG 'my window'
  50. RXSAY 'RC = 'RC
  51.  
  52. /* Send a command to OS/2. In this case, we're asking it to execute the
  53.     'hello' program. It probably won't find any such executable, and so REXX
  54.     will force a FAILURE and Rexx Dialog will post that 2 part message box,
  55.     but with a return string or number that OS/2 returned. You really have no
  56.     control over the error display and return type that is generated by other
  57.     than calls to Rexx Dialog commands. For this, you're always going to
  58.     see the REXX INTERPRETER ERROR message box regardless of how
  59.     you set RXERR. RXERR only controls the error return/display behavior
  60.     of Rexx Dialog functions */
  61. ADDRESS CMD 'hello'
  62.  
  63. /* Example of a syntax error. Uncomment and run script. Rexx Dialog will post
  64.     a REXX INTERPRETER ERROR message box containing some error message
  65.     provided by the interpreter (which also provides the value of RC). Then the
  66.     interpreter will halt the script due to a fatal error. Actually, the script will
  67.     never even execute the preceding instructions, because REXX checks the
  68.     syntax before running the script */
  69. /* RXSAY 'Hello" */
  70. EXIT
  71.  
  72. /* These simply return so that we can see all of the errors happening
  73.      without the script coming to an end after the first error */
  74. FAILURE:
  75.    RETURN
  76. ERROR:
  77.    RETURN
  78.