home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxlepsom.zip / Template.orx < prev    next >
Text File  |  1995-09-18  |  3KB  |  112 lines

  1. /* 
  2.     OREXX for 123G internal macro
  3. */
  4.  
  5. call 'dlfclass.cmd'
  6. call 'lepconst.cmd'
  7.  
  8. parse arg args
  9.  
  10. argc=words(args)
  11. if argc<1 then do
  12.   say 'Usage: Template.orx <LEPArgsArray instance address>'
  13.   return
  14. end
  15.  
  16. do i=1 to argc
  17.       argv.i=word(args,i)~strip('B')
  18. end
  19.  
  20. outlog=.stream~new('stdout.log')~~command('open write')
  21. errlog=.stream~new('stderr.log')~~command('open write')
  22.  
  23. call RedirectStdOutput
  24.  
  25. signal on syntax name ErrExit
  26. say 'Argument[1] = "'||argv.1||'" ('||c2x(argv.1)||')'
  27. somArgsArray=.LEPArgsArray~LEPArgumentsArrayFromLong(argv.1)
  28.  
  29. if somArgsArray=.nil then do
  30.    say 'Illegal 1st argument received, '
  31.    say 'it must be a valid LEPArgumentsArray instance pointer'
  32.    .Range~ClsDisplayError("Illegal LEPArgumentsArray object address");
  33.    return 1
  34. end
  35.  
  36. sz=somArgsArray~Size()
  37. do i=0 to sz-1
  38.     bb.i=somArgsArray~GetByNo(i)
  39.     say 'Arg['||i||']='|| bb.i
  40.     say bb.i~somGetClassName
  41. end
  42.  
  43. /*********************************************************************** 
  44.  *           Insert your code here
  45.  *
  46.  ***********************************************************************/
  47.  
  48.  
  49. /*********************************************************************** 
  50.  *           Epilog
  51.  *
  52.  ***********************************************************************/
  53.  
  54.  rc=outlog~close
  55.  rc=errlog~close
  56.  
  57. return
  58.  
  59. ErrExit:
  60. retcode=RC
  61.  
  62.  cnd=CONDITION('O')
  63.  say cnd
  64.  prg=cnd~entry('PROGRAM')
  65.  lNo=cnd~entry('POSITION')
  66.  errtxt=cnd~entry('ERRORTEXT')
  67.  errmsg=cnd~entry('MESSAGE')
  68. /*
  69.  errlog~lineout('Error '||RC||'occured in '||prg||'(line #'||lNo ||'): '||errtxt)
  70.  errlog~lineout(errmsg)
  71. */
  72.  
  73.  msg='Error '||rc||' occured at line '||sigl||' : '||Errortext(rc)
  74.  msg=msg||x2c('0D0A')||'** 'sigl'**: 'sourceline(sigl)
  75.  msg=msg||x2c('0D0A')||errmsg
  76.  say msg
  77.  .Range~ClsDisplayError(msg)
  78.  rc=outlog~close
  79.  rc=errlog~close
  80.  
  81. return retcode
  82.  
  83. RedirectStdOutput: procedure expose outlog errlog
  84. /****************************************************************
  85.    This function redirects standard output and error streams
  86.    to the files
  87. *****************************************************************/
  88.  
  89.  .local~setentry('output',.monitor~new(.stream~new(stdout)~~command(open nobuffer)))
  90.  
  91.  /* The following sets the destination. */
  92.  prev_stout=.output~destination(outlog)
  93.  
  94.  .local~setentry('error',.monitor~new(.stream~new(stderr)~~command(open nobuffer)))
  95.  
  96.  /* The following sets the destination. */
  97.  prev_stderr=.error~destination(errlog)
  98.  
  99. return
  100.  
  101. ::Class Coord    Public EXTERNAL 'SOM LEPCoord'
  102. ::Class M_Range  Public EXTERNAL 'SOM M_LEPRange'
  103. ::Class Range    Public EXTERNAL 'SOM LEPRange'
  104. ::Class LEPValue Public EXTERNAL 'SOM LEPValue'
  105. ::Class LEPInteger Public EXTERNAL 'SOM LEPInteger'
  106. ::Class LEPString Public EXTERNAL 'SOM LEPString'
  107. ::Class LEPReal Public EXTERNAL 'SOM LEPReal'
  108. ::Class LEPArgsArray  Public EXTERNAL 'SOM LEPArgumentsArray'
  109.  
  110.  
  111.  
  112.