home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 310.lha / DevKit_v1.2 / Rexx / UncommentBlock.ced < prev   
Encoding:
Text File  |  1980-12-03  |  2.1 KB  |  92 lines

  1. /************************************************************************
  2.  *
  3.  * UncommentBlock.ced                Copyright (c) 1989, Peter Cherna
  4.  *
  5.  * ARexx program for CygnusEd Professional.  Uncomments the highlighted
  6.  * block.  When the block was commented, open and close comments were
  7.  * replaced by '«*' and '*»', so change them back.  As well, any '«*'
  8.  * or '*»' were replaced by '««*' or '*»»' respectively, so change them
  9.  * back.
  10.  *
  11.  * Version 1.11:  August 20, 1989        Release 1.2:  August 29, 1989
  12.  *
  13.  ************************************************************************/
  14.  
  15.  
  16. /* Allow CygnusEd to pass status variables */
  17. options results
  18.  
  19. /* Tell ARexx to talk to CygnusEd */
  20. address 'rexx_ced'
  21.  
  22. cr = '0A'x
  23.  
  24. /*    Cut the original block out */
  25. cut block
  26.  
  27. /*    If the user did in fact have a block marked */
  28.  
  29. if result = 'RESULT' then
  30. DO
  31.     /*    Get the contents of the block buffer: */
  32.     status 60
  33.     string = result
  34.  
  35.     /*    Find the open comment: */
  36.     p = pos('/*'||cr,string)
  37.     if (p > 0) then
  38.         string = delstr(string,p,3)
  39.  
  40.     /*    Find the close comment: */
  41.     p = lastpos('*/'||cr,string)
  42.     if (p > 0) then
  43.         string = delstr(string,p,3)
  44.  
  45.     /*    Replace each occurrence of '«*' with an open comment,
  46.         provided this is not an occurrence of '««*' */
  47.     p = pos('«*',string,1)
  48.     DO while (p > 0)
  49.         if (p = 1) then
  50.             cut = 1;
  51.         else if (substr(string,p-1,1) ~= '«') then
  52.             cut = 1;
  53.         else
  54.             cut = 0;
  55.         if (cut) then
  56.         DO
  57.             string = left(string,p-1) || '/*' || substr(string,p+2)
  58.             p = pos('«*',string,p+2)
  59.         END
  60.         else
  61.         DO
  62.             string = left(string,p-1) || substr(string,p+1)
  63.             p = pos('«*',string,p+1)
  64.         END
  65.     END
  66.  
  67.     /*    Replace each occurrence of '*»' with a close comment,
  68.         provided that this is not an occurrence of '*»»' */
  69.     p = pos('*»',string,1)
  70.     DO while (p > 0)
  71.         if (substr(string,p+2,1) ~= '»') then
  72.         DO
  73.             string = left(string,p-1) || '*/' || substr(string,p+2)
  74.             p = pos('*»',string,p+2)
  75.         END
  76.         else
  77.         DO
  78.             string = left(string,p) || substr(string,p+2)
  79.             p = pos('*»',string,p+1)
  80.         END
  81.     END
  82.  
  83.     /*    Replace the block: */
  84.     text string
  85. END
  86. else
  87. DO
  88.     /*    Display problem (would be "No block marked") */
  89.     okay1 result
  90. END
  91. exit
  92.