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

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