BBS: Inland Empire Archive Date: 12-13-92 (13:59) Number: 382 From: PETER BARNEY Refer#: NONE To: TERRY ROSSI Recvd: NO Subj: Word wrap code Conf: (2) Quik_Bas
> I cannot fiqure out a good way to do a word wrap. I would like
> to have it break at the closest space to column 79 so the the
> next line begins with a complete word. Anybody have any ideas?
Here's a routine that will work with any length string:
SUB WordWrap (text$, wide%)
'
' This sub will take a string that is greater than wide% and split it up
' into multiple parts and store them in the previously-defined array,
' starting at element
'
Length = LEN(text$)
pointer = 1
DO
flag = 0
FOR j = pointer + wide% TO pointer STEP -1
IF MID$(text$, j, 1) = " " OR j = Length + 1 OR flag2 = 1 THEN
PRINT MID$(x$, pointer, j - pointer)
pointer = j
WHILE MID$(text$, pointer, 1) = " "
pointer = pointer + 1
WEND
flag = 1
flag2 = 0
EXIT FOR
END IF
NEXT
IF flag = 0 THEN flag2 = 1 'handle words that are greater than width
LOOP WHILE pointer < Length
END SUB
--- FMail 0.92
* Origin: Pete's Place - Toledo, Ohio (1:234/35.1)

Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET