home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxlepsom.zip / MacroLst.orx < prev    next >
Text File  |  1995-08-22  |  4KB  |  139 lines

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