Page 1 of 1
How to print newline in graphical console
Posted: Sat Mar 07, 2020 11:51 am
by endo
How can I print a line (or a content read from a file etc.) that includes newline (10, 13 or 0x0D0A) in graphical console?
Code: Select all
EnableGraphicalConsole(1)
PrintN("hello" + #CRLF$ + "world")
This prints out
on the console. If I remove
EnableGraphicalConsole then it works as expected.
I tried each combination of CR, LF, CRLF.
Note that below code also works as expected, so I don't know what
PrintN does different:
Re: How to print newline in graphical console
Posted: Sat Mar 07, 2020 1:38 pm
by BarryG
Quick workaround:
Code: Select all
Procedure PrintNN(text$)
crlf=CountString(text$,#CRLF$)+1
For n=1 To crlf
PrintN(StringField(text$,n,#CRLF$))
Next
EndProcedure
OpenConsole()
EnableGraphicalConsole(1)
PrintNN("hello"+#CRLF$+"world")
Input()
Re: How to print newline in graphical console
Posted: Sat Mar 07, 2020 2:10 pm
by Marc56us
You can also change mode as you want after open console.
In mode 0 CRLF work
Code: Select all
OpenConsole()
EnableGraphicalConsole(1)
PrintN("Console mode 1" + #CRLF$ + " Graphic (no CRLF)")
EnableGraphicalConsole(0)
PrintN("(Console mode 0" + #CRLF$ + "Text with CRLF)")
EnableGraphicalConsole(1)
ConsoleLocate(7, 8)
PrintN("Console mode 1")
Print("Press Return")
Input()
Re: How to print newline in graphical console
Posted: Sun Mar 08, 2020 9:07 pm
by endo
Thanks for the replies, both methods are useful.
Is it a bug of PureBasic or a known issue of Windows?
Re: How to print newline in graphical console
Posted: Mon Mar 09, 2020 4:26 am
by Olliv
ROFL !!
Thank you endo !
The best laugh since long time :
I can read << Hello >> << Vote >> << Vote >> << World >>.
(We would want to do it, that we cannot do it : random... I kept screenshoots)