StringFormat()

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

StringFormat()

Post 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.
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Re: StringFormat()

Post by helpy »

Windows 10 / Windows 7
PB Last Final / Last Beta Testing
Post Reply