home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 4 / CDPD_IV.bin / utilities / editors / textra / scripts / jforth_scripts / jfcomment.textra < prev    next >
Encoding:
Text File  |  1994-06-24  |  2.1 KB  |  86 lines

  1.      /******************************************************************
  2.      *   TEXTRA AREXX script -- Mike Haas, 1991, All Rights Reserved.  *
  3.      * Freely distributable ONLY as a component of the TEXTRA package. *
  4.      * This banner may not be removed or altered (improvements to the  *
  5.      *    actual program welcome).  Please document and send to me.    *
  6.      *        !!! PLACE THIS FILE IN YOUR REXX: DIRECTORY !!!          *
  7.      ******************************************************************/
  8.  
  9. /*
  10. ** JFComment.textra   Mike Haas
  11. **
  12. ** Convienient for commenting out sections of code in Forth or assembler
  13. **
  14. ** Just select some lines of text and enter:   JFComment
  15. **
  16. ** If the lines WERE commented out by a leading '\ ', it will be stripped.
  17. ** If they weren't, they are now!
  18. **
  19. ** note, you can enter a character such as...  JFComment *
  20. **
  21. ** and the program will add that, plus a space at the start of
  22. ** each line.  (It just uses '\' as a default)
  23. */
  24.  
  25. /* 00001 mdh 20-nov-92  check version (cause of 'CheckCancel') */
  26.  
  27. OPTIONS results
  28.  
  29. rex = 0; result = "NOTSUPPORTED"    /*00001*/
  30. textraversion
  31. parse var result maj min rex
  32. if (result == "NOTSUPPORTED") | (rex < 3) then do
  33.     notify "Textra V1.13 or later required for this script."
  34.     exit
  35. end
  36.  
  37. parse arg thechar
  38.  
  39. if (thechar == "") then
  40.    thechar = "\"
  41.  
  42. get select position
  43.  
  44. if (result == "NO SELECT") then   /* is nothing selected? */
  45.  
  46.     do
  47.         notify "There must be a select range to comment/uncomment."
  48.         exit
  49.     end
  50.  
  51.  
  52. /* yes, there is a selection, get it's boundaries */
  53. parse var result   startx ' ' starty ' ' endx ' ' endy
  54.  
  55. currx = startx
  56. curry = starty
  57.  
  58. /* if nothing on the endline is actually selected, don't include it */
  59. if (endx == 0) then  endy = endy - 1
  60.  
  61.  
  62.  
  63. do while (curry <= endy)
  64.  
  65.     CheckCancel; if (result == CANCEL) then exit
  66.  
  67.     do
  68.     
  69.        gotoxy 0 curry;   get cursor char
  70.        if (result == thechar) then do
  71.           del
  72.           get cursor char
  73.           if ((result == " ") | (result == "    ")) then do
  74.              del
  75.           end
  76.        end
  77.        else do
  78.           text thechar" ";
  79.        end
  80.        
  81.        curry = curry + 1
  82.     end
  83.  
  84. end
  85.           
  86.