home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / njpipes.zip / template2.nrx < prev    next >
Text File  |  1998-08-30  |  2KB  |  73 lines

  1. /* uncomment package if this code is in a subdirectory of one on your classpath
  2.  * and change xxxx to the name of the subdirectory
  3.  */
  4. -- package xxxx
  5.  
  6. options binary
  7.  
  8. import pipes.
  9.  
  10. /* To use methods in pipes\utils.nrx  add 'uses utils' to the class statement */
  11.  
  12. class template2 extends stage
  13.  
  14. /* objects shared between the ...setup and run methods */
  15.  
  16. properties private
  17.  
  18. parm  = rexx
  19. rc    = int
  20.  
  21. /* method to initialize a stage.  Only called once unless the arg() changes */
  22.  
  23. method template2_setup() private signals StageError
  24.  
  25.    a = arg()
  26.  
  27.    parm = a
  28.  
  29.    if rc<>0 then
  30.       signal StageError(11,'Error - template2 had setup problems')
  31.  
  32.  
  33. method run()
  34.  
  35.    /* insert objects that need to be reset every invokation here */
  36.  
  37.    rc  = 0
  38.  
  39.    do -- to catch the terminating StageError
  40.  
  41.       /* call ...setup only if required */
  42.  
  43.       if doSetup() then
  44.          template2_setup()
  45.  
  46.       /* setup code that must execute every time the stage object runs
  47.        *
  48.        * if there are setup problems then
  49.        *    signal StageError(11,'termplate1 had this error')
  50.        *
  51.        */
  52.  
  53.       /* body of stage */
  54.  
  55.       loop forever
  56.          robject = rexx peekto()          -- pass only rexx objects
  57.          output(robject)
  58.          readto()
  59.  
  60.       /* catch any cast exceptions that occur and issue a StageError */
  61.  
  62.       catch ClassCastException
  63.          signal StageError(13,'Error - Input not a rexx object')
  64.       end
  65.  
  66.    catch err=StageError
  67.    end
  68.  
  69.    rc = err.rc()
  70.  
  71. exit(rc*(rc<>12))
  72.  
  73.