Page 1 of 1

StringFormat()

Posted: Wed Mar 06, 2013 9:23 am
by Rescator
I think PureBasic would be better served to support:

Code: Select all

Debug "He said \"hello\" to her"
;Output is:
;He said "hello" to her
And

Code: Select all

Debug "He said\r\n \"hello\" to her"
;Outputs is:
;He said
;"hello" to her

Code: Select all

Debug "He said\r\n \"hello\" to \t her"
;Outputs is:
;He said
;"hello" to         her

Code: Select all

Debug "He said\r\n \"hello\" to \t her \\r"
;Outputs is:
;He said
;"hello" to         her \r
(and this is the important part)

Code: Select all

Debug "He said\r\n \"hello\" to \t her \"
;Outputs is:
;He said
;"hello" to         her \
Note that a single \ remains such, important when dealing with file paths for example.

However, PureBasic may benefit much more from a StringFormat() function that supports this,
thus letting normal strings remain such (and fast processing since it's just concatenation),
Thus:

Code: Select all

text$=StringFormat("He said\n\r \"hello\" to \t her \")
Would be the same as doing:

Code: Select all

text$="He said"+#CRLF$+" "+#DQUOTE$+''hello"+#DQUOTE$+" to "+Chr(9)+" her \"

Oh and StringFormat() is just a suggestion on what to call this function.

Re: StringFormat()

Posted: Wed Mar 06, 2013 10:25 am
by helpy