home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epmrex.zip / GENERIC.ERX < prev    next >
Text File  |  1992-08-28  |  2KB  |  50 lines

  1. /*
  2.  * Name        GENERIC.ERX
  3.  *
  4.  * Author      Ralph E. Yozzo, Larry Margolis
  5.  *
  6.  * Function    An example EPM REXX macro.  Used by RXMENU.ERX
  7.  */
  8. arg function .
  9. if function='' then function='TRANSLATE'
  10. select
  11.   when function='LEFT' | function='RIGHT' | function='CENTER' then boundary=',80'
  12.   otherwise boundary=''
  13. end
  14. if function='REVERSE' then function_call = "reverse(getline.1)"  /* Don't strip for Reverse() */
  15.                       else function_call = "strip("function"(strip(getline.1)"boundary"),'t')"
  16.  
  17. 'extract /getmark/filename'
  18. if getmark.0 >  0 then 'dokey a+Y'  /* Move to beginning of mark, even if in a different file. */
  19. oldfilename = filename.1
  20. 'extract /last/modify/autosave/line/filename'
  21. call etksetfilefield 'autosave', 0   /* Turn off autosaving... */
  22. if getmark.0 >  0 then do
  23.    firstline=getmark.1
  24.    lastline=getmark.2
  25.    marked = 'marked lines'
  26.    if filename.1 <> oldfilename then
  27.       'sayerror Working on marked area in' filename.1 '...'
  28.    else
  29.       'sayerror Working on marked area...'
  30. end ; else do
  31.    firstline=1
  32.    lastline=last.1
  33.    marked = ''
  34.    'sayerror Working on file...'
  35. end
  36. limit = lastline - firstline + 1
  37.  
  38. do i = firstline to lastline         /* For every line in the file or mark, */
  39.    call etksetfilefield 'line', i    /* make that line the current line */
  40.    'extract /getline'
  41.    interpret "call etkreplacetext" function_call
  42.    j = i - firstline + 1
  43.    if j // 50 = 0 then
  44.       'sayerror Processed' j 'lines of' limit marked
  45. end
  46. 'sayerror 0'
  47. call etksetfilefield 'modify', modify.1 + 1   /* Treat as a single change */
  48. call etksetfilefield 'autosave', autosave.1   /* Restore autosaving */
  49. call etksetfilefield 'line', line.1           /* Restore current line */
  50.