home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d7xx / d770 / uedit.lha / Uedit / Jenkins2.LZH / ExchangeNames < prev    next >
Text File  |  1991-04-08  |  4KB  |  100 lines

  1. ExchangeNames
  2. =============================================================================
  3.  
  4. COPYRIGHT 1991
  5. Robert A. Jenkins, Ph.D.
  6. 22901 Shagbark Lane
  7. Miller Woods, IL 60411
  8. (708) 758-0344
  9. All Rights Reserved
  10. Rick Stiles may distribute it as he pleases.
  11.  
  12. =============================================================================
  13. I wrote this to make it easy to change names in Modula-2 programs
  14. when you are cleaning up the code and realize that the naming
  15. convention is not clear.  
  16.  
  17.     1. Use buildIndex (shftAlt-mouseDown) to compile a list of
  18. words in buf41.  
  19.     2.  Save and use Amiga system sort function "sort >list.sort
  20. list" to sort the list.
  21.     3.  Use grep /~\(.*\n\)\1/\1/(see advanced examples) to
  22. delete duplicates.  
  23.     4. Use learn (ctl-s) to duplicate the words if that will help
  24. in composing the new words.  Enter the replacement on the line
  25. with at least one space between.  You might tab it if you will
  26. use the list a lot.
  27.  
  28. =============================================================================
  29. Exchange words in curFile as per list in buf41
  30. <ctl-q:
  31. equateNum(n0,0)
  32. if(askYesNo("Confirm each replacement?")) equateNum(n0,1)
  33. equateNum(n50,curFile)      ..now use buf[n50] instead of curFile
  34.                             ..so debugging works
  35. moveCursor(buf41,sFile)
  36. while (gtLoc(buf41,eFile,atCursor)) {      ..to end
  37.    ..get search word
  38.    equateLoc(buf41,sHilite,atCursor)       ..always at sLine
  39.    equateLoc(buf41,sInvert,atCursor)
  40.    while(!is(buf41,whiteSpace)) moveCursor(buf41,eChar)
  41.    equateLoc(buf41,eHilite,atCursor)
  42.    freeBuf(buf49)
  43.    insertRgn(buf49,sFile,buf41,hilite)
  44.    setSearch(buf49)
  45.    ..editBuf(buf41)..debug
  46.    ..alertUser("search word")..debug
  47.    
  48.    ..get replace word
  49.    moveCursor(buf41,eLine)
  50.    equateLoc(buf41,eHilite,atCursor)
  51.    equateLoc(buf41,eInvert,atCursor)
  52.    moveCursor(buf41,sWord) ..move off of eLine
  53.    while(!is(buf41,whiteSpace)) moveCursor(buf41,sChar)
  54.    if(is(buf41,whiteSpace)) moveCursor(buf41,eChar)
  55.    equateLoc(buf41,sHilite,atCursor)
  56.    freeBuf(buf48)
  57.    insertRgn(buf48,sFile,buf41,hilite)
  58.    ..monitor progress
  59.    freeBuf(buf50)
  60.    insertRgn(buf50,sFile,buf41,invert)
  61.    putMsg(buf50)
  62.    ..editBuf(buf41)..debug
  63.    ..alertUser("search and replace word")..debug
  64.    
  65.    ..editBuf(buf[n50])..debug
  66.    moveCursor(buf[n50],sFile)
  67.    ..alertUser("starting search from top of curFile")
  68.    while (gtLoc(buf[n50],eFile,atCursor)) {
  69.       if (not search(buf[n50],sHilite,eHilite,1)) goto label(1)
  70.       ..alertUser("candidate")
  71.       
  72.       ..check for whole word, don't replace part of identifier
  73.       equateLoc(buf[n50],locA,sHilite)
  74.       equateLoc(buf[n50],locB,eHilite)
  75.       moveCursor(buf[n50],eWord)
  76.       ..alertUser("check right")..debug
  77.       if (gtLoc(buf[n50],atCursor,locB)) {
  78.          ..alertUser("alphanum on right")..debug
  79.          goto label(0) }
  80.       moveCursor(buf[n50],sWord)
  81.       ..alertUser("check left")..debug
  82.       if (gtLoc(buf[n50],locA,atCursor)) {
  83.          ..alertUser("alphanum on left")..debug
  84.          moveCursor(buf[n50],eWord)
  85.          goto label(0) }
  86.       ..search=whole word
  87.       if(eqNum(n0,1)) {
  88.          vScroll(atCursor)
  89.          if(askYesNo("Replace as on msg line?")) {
  90.             clearRgn(buf[n50],hilite)
  91.             insertRgn(buf[n50],atCursor,buf48,all) } }
  92.       ..alertUser("replaced")..debug
  93.       label(0) }
  94.    label(1)  ..exchange is done
  95.    ..editBuf(buf41)..debug
  96.    ..go to start of next search, if any
  97.    moveCursor(buf41,sLine)
  98.    moveCursor(buf41,downLine) }
  99. putMsg("Done")
  100. >