home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************
- *
- * UncommentBlock.ced Copyright (c) 1989, Peter Cherna
- *
- * ARexx program for CygnusEd Professional. Uncomments the highlighted
- * block. When the block was commented, open and close comments were
- * replaced by '«*' and '*»', so change them back. As well, any '«*'
- * or '*»' were replaced by '««*' or '*»»' respectively, so change them
- * back.
- *
- * Version 1.11: August 20, 1989 Release 1.2: August 29, 1989
- *
- ************************************************************************/
-
-
- /* Allow CygnusEd to pass status variables */
- options results
-
- /* Tell ARexx to talk to CygnusEd */
- address 'rexx_ced'
-
- cr = '0A'x
-
- /* Cut the original block out */
- cut block
-
- /* If the user did in fact have a block marked */
-
- if result = 'RESULT' then
- DO
- /* Get the contents of the block buffer: */
- status 60
- string = result
-
- /* Find the open comment: */
- p = pos('/*'||cr,string)
- if (p > 0) then
- string = delstr(string,p,3)
-
- /* Find the close comment: */
- p = lastpos('*/'||cr,string)
- if (p > 0) then
- string = delstr(string,p,3)
-
- /* Replace each occurrence of '«*' with an open comment,
- provided this is not an occurrence of '««*' */
- p = pos('«*',string,1)
- DO while (p > 0)
- if (p = 1) then
- cut = 1;
- else if (substr(string,p-1,1) ~= '«') then
- cut = 1;
- else
- cut = 0;
- if (cut) then
- DO
- string = left(string,p-1) || '/*' || substr(string,p+2)
- p = pos('«*',string,p+2)
- END
- else
- DO
- string = left(string,p-1) || substr(string,p+1)
- p = pos('«*',string,p+1)
- END
- END
-
- /* Replace each occurrence of '*»' with a close comment,
- provided that this is not an occurrence of '*»»' */
- p = pos('*»',string,1)
- DO while (p > 0)
- if (substr(string,p+2,1) ~= '»') then
- DO
- string = left(string,p-1) || '*/' || substr(string,p+2)
- p = pos('*»',string,p+2)
- END
- else
- DO
- string = left(string,p) || substr(string,p+2)
- p = pos('*»',string,p+1)
- END
- END
-
- /* Replace the block: */
- text string
- END
- else
- DO
- /* Display problem (would be "No block marked") */
- okay1 result
- END
- exit
-