Re: Word wrap code

 BBS: Inland Empire Archive
Date: 12-10-92 (00:21)             Number: 297
From: ROB MCKEE                    Refer#: NONE
  To: TERRY ROSSI                   Recvd: NO  
Subj: Re: Word wrap code             Conf: (2) Quik_Bas
Hi Terry, In response to:
 TR> out how to handle a problem.  I need to break a line that
 TR> i read in from file A into two line in file B, I am able
 TR> to do that but I cannot fiqure out a good way to do a word
 TR> wrap.  Right now the software breaks the line at column 79
 TR> regardless of where the word ends.  I would like to have
 TR> it break at the closest space to column 79 so the the next
 TR> line begins with a complete word.   Anybody have any ideas?

  --------------- Code Fragment --------------
  ' A$ is the original Line
 DO
     a$ = RTRIM$(a$)
     IF LEN(a$) > 79 THEN
        FOR t = 79 TO 1 STEP -1
            IF MID$(a$, t, 1) = " " THEN
                b$ = MID$(a$, t + 1)
                a$ = LEFT$(a$, t - 1)
                EXIT FOR
            END IF
        NEXT t
            'For insertion in a Varible array
        LineCount = LineCount + 1
        Line$(LineCount)= a$
            ' Could also be
        PRINT a$
        a$ = b$
     ELSE
            'For insertion in a Varible array
        LineCount = LineCount + 1
        Line$(LineCount)= a$
            ' Could also be
        PRINT a$
        b$ = ""
     END IF
         'For insertion in a Varible array
     LineCount = LineCount + 1
     Line$(LineCount)= a$
         ' Could also be
     PRINT a$
 LOOP UNTIL b$ = ""
  --------------- Code Fragment --------------
    Hope this helps you....

                               TTYL -Rob

 ------------------------------ 8< ---------------------------

--- EZPoint V2.1
 * Origin: Flyer Proof Computer Services V# 510-237-8091 (1:125/1212.13)
Outer Court
Echo Basic Postings

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