home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nibble Magazine
/
nib41b.dsk
/
NEWTEXT.bas
< prev
next >
Wrap
BASIC Source File
|
2023-02-26
|
957b
|
19 lines
10 REM PROGRAM NEWTEXT
20 REM IT IS A ROUTINE TO DEMONSTRATE A
30 REM WORDWRAP TECHNIQUE IN BASIC
40 REM IT IS SET FOR A 40 COLUMN SCREEN
50 REM BUT CAN HANDLE LINES OF ANY LENGTH
60 DIM T$(10): REM TOTAL NUMBER OF LINES
70 HOME :CHAR = 1
80 GOTO 100
90 LN = LN +1:T$(LN) = L$:L$ = "": RETURN
100 GET A$: IF A$ = CHR$(13) THEN CHAR = 1:SLOC = 0: GOSUB 90
110 CHAR = CHAR +1:L$ = L$ +A$: IF CHAR <40 OR A$ = " " THEN 170
120 IF SLOC = 0 THEN GOSUB 90:L$ = "": PRINT :CHAR = 1: GOTO 100
130 SS = 40 -SLOC -1: FOR J = 1 TO SS: PRINT CHR$(8);: NEXT J: FOR J = 1 TO SS: PRINT " ";: NEXT J
140 IF SLOC = LEN(L$) THEN NXTL$ = "": GOSUB 90: GOTO 100
150 NXTL$ = RIGHT$(L$, LEN(L$) -SLOC):L$ = LEFT$(L$,SLOC): FOR J = LEN(L$) +1 TO 40:L$ = L$ +" ": NEXT J
160 GOSUB 90:L$ = NXTL$: PRINT : PRINT L$;:CHAR = LEN(L$) +1:NXTL$ = "":SLOC = 0: GOTO 100
170 IF A$ = " " THEN SLOC = CHAR -1: REM SPACE LOCATION
180 PRINT A$;
190 GOTO 100