/*************************************************************\
** $VER: Format.ced 1.0                                      **
** By  : James Allen (AKA $LiNg$HoT)                         **
** Date: September 94                                        **
** Rel : May 96.                                             **
** Description :                                             **
**                                                           **
** 	- Formats every paragraph in the current file.          **
**   - Doesnt format if line has NEWLINE in 1st 10 chars.    **
**   - Status line on menu bar, shows progress.              **
**   - Press a key to abort at any time.                     **
**   - IMPORTANT: Place spaces between or indent paragraphs. **
**                Otherwise paragraphs will merge!           **
**                                                           **
\*************************************************************/

address 'rexx_ced'

OPTIONS RESULTS

CEDTOFRONT

STATUS NUMLINES
NumberOfLines = RESULT + 1

STATUS LINENUMBER
CurLine = RESULT + 1

do while( CurLine ~= NumberOfLines & left(linebuf,2) ~= '##')
	STATUS LINEBUFFER
	linebuf = RESULT
	/* If NEWLINE found in first 10 characters, then dont format */
	If POS('0a'x,left(RESULT,10)) = 0 then 
		WITH FILL
	Else
		DOWN

	LASTKEY
	/* Check for a keystroke (~= -1) which is not an key release (< 128) */
	IF (RESULT ~= -1) & (WORD( RESULT, 1 ) < 128) THEN DO
		CEDTOFRONT
		OKAY1 "Format Aborted!"
		EXIT
	END

	STATUS LINENUMBER
	CurLine = RESULT + 1
	STATUS NUMLINES
	NumberOfLines = RESULT + 1

	DM "LineNumber: "CurLine" NumLines:  "NumberOfLines
End 
DM ""
