
NPrint() and NPrintN()
NPrint() and NPrintN()
yes, i'm a lazy 

Re: NPrint() and NPrintN()
What do they do?
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
-
- Addict
- Posts: 1648
- Joined: Mon Sep 20, 2004 3:52 pm
- Contact:
Yes!dracflamloc wrote:In all honesty I think it needs to.
like in C:
printf("\nThis is on a new line\n")
so in PB:
Print("\nThis is on a new line\n")

Here's a small workaround for the CRLF problem (windows only):
Code: Select all
Procedure _Print(hConsole.l, strToWrite.s)
WriteConsole_(hConsole, strToWrite, Len(strToWrite), @cWritten, #NULL)
ProcedureReturn cWritten
EndProcedure
hConsole = OpenConsole()
_Print(hConsole, "hello" + #LF$ + "world")
Input()
CloseConsole()
Code: Select all
OpenConsole()
u32dll = OpenLibrary(#PB_Any, "user32.dll")
*f = IsFunction(u32dll, "wsprintfA")
If *f
buf.s = Space(64)
CallFunctionFast(*f, @buf.s, "int=%i, hex=%08x", 42, 8192)
Print(buf)
EndIf
CloseLibrary(u32dll)
Input()
CloseConsole()
Good programmers don't comment their code. It was hard to write, should be hard to read.
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
NPrintN is a great idea
I agree, this would be nice to have:
Code: Select all
Procedure NPrintN(string.s)
PrintN("")
PrintN(string)
EndProcedure
OpenConsole()
NPrintN("Testing")
wait$=Input()
CloseConsole()
Re: NPrintN is a great idea
I don't understand... Print() and PrintN() already exist, so what's the problem?
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
Re: NPrintN is a great idea
Yes, but there is requested NPrint() and NPrintN(), this is, a CR before print the text.PB wrote:I don't understand... Print() and PrintN() already exist, so what's the problem?
Re: NPrintN is a great idea
Oh, now I see. 

I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
-
- Addict
- Posts: 1648
- Joined: Mon Sep 20, 2004 3:52 pm
- Contact:
Unreadable?!?!?!?Psychophanta wrote:Noooo, that's uglyest. the called Escape senquences are hightly unreadable.dracflamloc wrote:Does PB accept the standard characters for that kind of thing? It does not. In all honesty I think it needs to.
like in C:
printf("\nThis is on a new line\n")
so in PB:
Print("\nThis is on a new line\n")
Escape characters are a godsend in complex console apps.
I mean:
Print("Blah App\n1.0\nCopyright 2005")
is a hell of a lot better than:
Print("Blah App"+chr(13)+chr(10)+"1.0"+chr(13)+chr(10)+"Copyright 2005")
and having to use three lines of code just to print a header is ridiculus.
Also, its not like you would HAVE to use them...
-
- Enthusiast
- Posts: 362
- Joined: Wed Aug 06, 2003 2:49 pm
- Location: Venice - Italy, Japan when possible.
- Contact:
Agree with dracflamloc!
In fact I used the following to make my life easy(er):

In fact I used the following to make my life easy(er):
Code: Select all
Procedure .s ParseText(txt.s)
txt=ReplaceString(txt,"\n",Chr(10),1)
txt=ReplaceString(txt,"\t",Chr(9),1)
ProcedureReturn txt
EndProcedure

- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
\n inside "" are 2 characters: \ and n
\t inside "" are 2 characters: \ and t
chr(10) means 1 character, the one which ascii is 10
chr(13) means 1 character, the one which ascii is 13
Can't imagine a way to do it more legible, but something like this:
AsciiCharacter(10) or AsciiCharacter(13) ...
So sorry, but no agree with you.
\t inside "" are 2 characters: \ and t
chr(10) means 1 character, the one which ascii is 10
chr(13) means 1 character, the one which ascii is 13
Can't imagine a way to do it more legible, but something like this:
AsciiCharacter(10) or AsciiCharacter(13) ...
So sorry, but no agree with you.
-
- Addict
- Posts: 1648
- Joined: Mon Sep 20, 2004 3:52 pm
- Contact: