/* ** WordWrap ** ** $VER: WordWrap 1.1.0 (5.11.93) ** ** This ARexx script contains a function which performs word wrapping on ** a given text string. ** ** INPUTS ** NumRows -- maximum number of rows of text. ** NumCols -- maximum number of columns of text. ** RawText -- unformatted text string. ** ** RETURNS ** FormattedText -- formatted text string. Use the 'Result' ** variable to retrieve this string. ** ** NOTE: This function does not properly handle embedded NEWLINE control ** characters. ** ** This script should work with current versions of ARexx. ** ** Copyright © 1992-1993 Elastic Reality, Inc. ** All Rights Reserved */ OPTIONS RESULTS NL = '0A'X PARSE ARG NumRows NumCols RawText CharPos = 1 RawTextLen = LENGTH( RawText ) Rows = 1 FormattedText = "" DO WHILE ((CharPos <= RawTextLen) & (Rows <= NumRows)) RawRowText = SUBSTR( RawText, CharPos, NumCols ) LastSpacePos = LASTPOS( ' ', RawRowText ) IF (LastSpacePos ~= 0) THEN RawRowText = LEFT( RawRowText, LastSpacePos-1 ) FormattedText = FormattedText || NL || STRIP( STRIP( RawRowText, "B", " "), "B", " " ) CharPos = CharPos + LENGTH( RawRowText ) Rows = Rows + 1 END RETURN FormattedText /* ** strict format (no word wrap): ** ** RawTextLen = LENGTH( RawText ) ** FormattedText = "" ** DO Row = 0 TO (NumRows-1) UNTIL ((Row*NumCols+NumCols) > RawTextLen) ** FormattedText = FormattedText || NL || SUBSTR( RawText, (Row*NumCols+1), NumCols ) ** END */