home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff297.lzh / DevKit / Rexx / CommentBlock.ced < prev    next >
Text File  |  1989-12-29  |  2KB  |  76 lines

  1. /************************************************************************
  2.  *
  3.  * CommentBlock.ced                    Copyright (c) 1989, Peter Cherna
  4.  *
  5.  * ARexx program for CygnusEd Professional.  Comments out the highlighted
  6.  * block.  Because comments in C don't nest, all comment brackets within
  7.  * the block are changed to '«*' and '*»'.  Any existing '«*' or '*»'
  8.  * are changed to '««*' or '*»»' respectively, ad infinitum.
  9.  *
  10.  * Version 1.11:  August 20, 1989        Release 1.2:  August 29, 1989
  11.  *
  12.  ************************************************************************/
  13.  
  14.  
  15. /* Allow CygnusEd to pass status variables */
  16. options results
  17.  
  18. /* Tell ARexx to talk to CygnusEd */
  19. address 'rexx_ced'
  20.  
  21. cr = '0A'x
  22.  
  23. /*    Cut the original block out */
  24. cut block
  25.  
  26. /*    If the user did in fact have a block marked */
  27.  
  28. if result = 'RESULT' then
  29. DO
  30.     /*    Get the contents of the block buffer: */
  31.     status 60
  32.     string = result
  33.  
  34.     /*  Replace each occurrence of a '«*' with a '««*' */
  35.     p = pos('«*',string,1)
  36.     DO while (p > 0)
  37.         string = left(string,p) || '«' || substr(string,p+1)
  38.         p = pos('«*',string,p+3);
  39.     END
  40.  
  41.     /*  Replace each occurrence of a '*»' with a '*»»' */
  42.  
  43.     p = pos('*»',string,1)
  44.     DO while (p > 0)
  45.         string = left(string,p) || '»' || substr(string,p+1)
  46.         p = pos('*»',string,p+3)
  47.     END
  48.  
  49.     /*  Replace each occurrence of an open comment with a '«*' */
  50.  
  51.     p = pos('/*',string,1)
  52.     DO while (p > 0)
  53.         string = left(string,p-1) || '«*' || substr(string,p+2)
  54.         p = pos('/*',string,p+2)
  55.     END
  56.  
  57.     /*  Replace each occurrence of a close comment with a '*»' */
  58.  
  59.     p = pos('*/',string,1)
  60.     DO while (p > 0)
  61.         string = left(string,p-1) || '*»' || substr(string,p+2)
  62.         p = pos('*/',string,p+2)
  63.     END
  64.  
  65.     /*    Replace the block, surrounded by comments: */
  66.     text '/*'||cr
  67.     text string
  68.     text '*/'||cr
  69. END
  70. else
  71. DO
  72.     /*    Display problem (would be "No block marked") */
  73.     okay1 result
  74. END
  75. exit
  76.