LB Booster
Programming >> Liberty BASIC language >> Line length limit for text output from console app
http://lbb.conforums.com/index.cgi?board=lblang&action=display&num=1500141024

Line length limit for text output from console app
Post by CirothUngol on Jul 15th, 2017, 5:50pm

My console TREE.EXE replacement seems to be working great. Quite a bit slower than the original, but with several more options and easily capable of handling full trees on drives with hundreds of thousands of files and folders. While testing, I noticed that there seems to be a limit of around 100 characters to the length of a line PRINTed in the console when the output is redirected (saved) to a text file. Please look at the following test Code:
' test for redirected console output

FOR i = 1 TO 255
    v$ = v$; "-"
    PRINT v$
NEXT i

v$ = SPACE$(70)
FOR i = 71 TO 255
    v$ = v$; "-"
    PRINT v$
NEXT i

v$ = ""
FOR i = 2 TO 255 STEP 2
    v$ = v$; "- "
    PRINT v$
NEXT i

v$ = ""
FOR i = 5 TO 255 STEP 5
    v$ = v$; "---- "
    PRINT v$
NEXT i

END 
Compile as a console app and redirect the output to a text file (TEST.EXE>test.txt). It seems as if spaces get converted to carriage returns at around character #102, like it's creating pages from the output (Incidently, the MAINWIN seems to do this at around character #240).
Is there a way to avoid this? TREE requires the ability to output lines of inordinate length (255+). Hopefully I've done something wrong and there is a simple solution.
Re: Line length limit for text output from console
Post by Richard Russell on Jul 15th, 2017, 8:05pm

on Jul 15th, 2017, 5:50pm, CirothUngol wrote:
TREE requires the ability to output lines of inordinate length (255+).

I've always thought of the Windows console as being an old-fashioned teletype-like interface with a line length of no more than 80 characters or so. Even when redirecting the output to a file, I would have expected that file to be compatible with a standard 'line printer' page width.

Anyway I've made a note to allow longer lines in a future version of LBB, should there be one.

Richard.

Re: Line length limit for text output from console
Post by CirothUngol on Jul 17th, 2017, 9:50pm

Thanks for the consideration, hopefully it may be included in some future update... I'm just glad to know that I wasn't doing anything wrong. ^_^

Re: Line length limit for text output from console
Post by Richard Russell on Jul 19th, 2017, 09:49am

on Jul 15th, 2017, 5:50pm, CirothUngol wrote:
Is there a way to avoid this?

Actually I think there is a workaround of sorts. If you output the string in chunks of no more than (say) 80 characters I would not expect the wraparound effect to occur. Try this for example:

Code:
FOR i = 1 TO 255
    v$ = v$; "-"
    PRINT LEFT$(v$,80);
    PRINT MID$(v$,81,80);
    PRINT MID$(v$,161,80);
    PRINT MID$(v$,241,80)
NEXT i 

This will affect the output only when compiled as a console application.

Richard.

Re: Line length limit for text output from console
Post by Richard Russell on Jul 21st, 2017, 06:40am

on Jul 19th, 2017, 09:49am, Richard Russell wrote:
Actually I think there is a workaround of sorts.

Here's a more elegant solution which works for an arbitrary length of string:

Code:
FOR i = 1 TO 255
    v$ = v$; "-"
    CALL print v$
NEXT i
END

SUB print a$
    WHILE LEN(a$) > 80
        PRINT LEFT$(a$,80);
        a$ = MID$(a$,81)
    WEND
    PRINT a$
END SUB 

Obviously this isn't as satisfactory as modifying LBB so it doesn't wrap console output, which I will attempt in the next release, but it's a temporary fix.

Richard.