home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / samples / rexx / ktguard.cmd < prev    next >
OS/2 REXX Batch file  |  1999-05-11  |  2KB  |  31 lines

  1. /******************************************************************************/
  2. /*  ktguard                  Object REXX Samples                              */
  3. /*                                                                            */
  4. /*  A guard instruction example.                                              */
  5. /*                                                                            */
  6. /*  This program demonstrates the use of the start method and the guard       */
  7. /*  instruction to control execution of several programs.  In this sample,    */
  8. /*  the programs are controlled by one 'guarded' variable.                    */
  9. /******************************************************************************/
  10.  
  11. /* Define sample class and add methods we will use */
  12. sample = .object~subclass('Sample')
  13. m1 = 'expose g; guard off when g; use arg text; say text'
  14. sample~define('WAIT_ON',  m1)
  15. m2 = 'expose g; use arg g'
  16. sample~define('SETGUARD', m2)
  17.  
  18. /* Start up 10 invocations of WAIT_ON */
  19. a = sample~new~~setguard(0)                 /* g is false so programs will    */
  20.                                             /* wait on guard instruction      */
  21. do i = 1 to 10
  22.   say 'Start invocation' right(i,2) '(and wait)'
  23.   a~start('WAIT_ON', '  Invocation' right(i,2) 'completing')
  24. end
  25.  
  26. /* Now let them all run */
  27. say 'Press enter to set guard expression true...'
  28. parse pull .
  29. a~setguard(1)                               /* Setting g to 1 allows programs */
  30.                                             /* to run.                        */
  31.