home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_progs
/
txttools
/
tked.lha
/
rexx
/
Format-Marked.tked
< prev
next >
Wrap
Text File
|
1992-06-26
|
2KB
|
74 lines
/**
** ARexx-program to format all lines of a marked text to a requested length
**
** Doesn't work perfectly in each case, but better than nothing
**
** © Tom Kroener '92
**
**/
options results
address 'TKEd.1' /* Portname of the first started TKEd */
FirstMarkedLine /* Go to start */
Start = result
IF Start = -1 THEN /* No block marked => EXIT */
DO;
Request1 "No lines marked!"
EXIT 10
END;
GetLineNr /* Current line = last marked line +1*/
End = result-1
UnMarkBlock
GetNumber "Enter length" /* Length of a line after format */
Length = result+1
GotoLine Start
DO WHILE Start <= End /* Format until it reaches the last line */
GetLineLen
IF result > 0 THEN /* Skip blank lines */
DO;
DO WHILE result < Length /* Line too short => join two lines */
Cursor "DOWN"
JoinLines
GetLineLen
END
GotoColumn (Length) /* Goto end of the line */
PreviousWord /* Words won't be cuted */
Cursor "RIGHT"
MakeReturn /* Split the line */
Cursor "UP" /* Goto previous line */
BeginOfLine /* Goto beginning of the line */
GetChar
DO WHILE result = " " /* Remove leading spaces */
Del
GetChar
END;
GetLineLen
DO WHILE result < Length /* As long as the line is too short */
GetLineNr /* position in the text*/
YPos = result
NextWord /* 1 word left */
GetLineNr
IF result > YPos THEN /* If NextWord jumps to the next line
=> go to beginning */
DO;
BeginOfLine
Cursor "UP"
END;
WriteChar " " /* Insert 1 blank */
GetLineLen
END;
END;
GetLineNr
Current = result
LastLine
IF result = Current THEN /* End of text => EXIT */
EXIT 0
Start = Start + 1 /* Increment counter */
Cursor "DOWN"
END;
EXIT 0