Line Wrappingby qbguy (no login)1) Reading: load line, search the last space on screen, cut after the space and save the rest for the line below.... ' QBASIC line wrapper ' Wraps long lines to 80 characters and pads all lines to 80 characters INPUT "File to process: "; FILE$ INPUT "Output file; "; OUT$ OPEN FILE$ FOR INPUT AS #1 OPEN OUT$ FOR OUTPUT AS #2 DIM THELIN AS STRING DO WHILE NOT EOF(1) LINE INPUT #1, LINEIN$ FOR I = 1 TO LEN(LINEIN$) CH$ = MID$(LINEIN$, I, 1) THEWORD$ = THEWORD$ + CH$ IF CH$ = " " THEN IF LEN(THELIN + THEWORD$) <= 81 THEN THELIN = THELIN + THEWORD$ ELSE PRINT #2, LEFT$(THELIN + SPACE$(80), 80) THELIN = THEWORD$ END IF THEWORD$ = "" END IF NEXT PRINT #2, "" LOOP CLOSE It creates a new file and pads all lines to 80 characters so that you can open the new file either for RANDOM with LEN = 82 (80 + CRLF) or as a sequential file. from IP address 75.16.112.183 |
| Response Title | Author and Date |
| * 80 is max PRINT line. OP is using 75 for indentations | on Jul 23 |