Page 1 of 2
C like escape sequenses for strings.
Posted: Thu Feb 01, 2007 8:55 pm
by Tipperton
That way we could do something like
instead of having to do
Code: Select all
msg.s = "Hello" + Chr(13) + Chr(10) + "There!"
Posted: Thu Feb 01, 2007 9:01 pm
by bembulak
Yes, this would be good! I like those Escape squences, also for TABS, ....
Posted: Thu Feb 01, 2007 9:08 pm
by freak
So all filenames must be written like this: "C:\\Program Files\\..." brrr!

Posted: Thu Feb 01, 2007 9:23 pm
by WishMaster
I personally don't think that's a good idea.
For users, maybe. But not for programmers...
Posted: Thu Feb 01, 2007 9:27 pm
by gogo
I like verbatim strings as found in C# ....
Code: Select all
string s=@"bla bla bla c:\folder\file.ext
and I can continue on next line
and another line ";
Ok, the @ is used for getting the address. In PB we just need to find another character.
Posted: Thu Feb 01, 2007 9:37 pm
by ts-soft
freak wrote:So all filenames must be written like this: "C:\\Program Files\\..." brrr!

and URL: "http:////www.purebasic.com//index.html"

Posted: Thu Feb 01, 2007 10:24 pm
by traumatic
ts-soft wrote:and URL: "http:////www.purebasic.com//index.html"

lol no, why do you think that?
Posted: Thu Feb 01, 2007 10:52 pm
by SCRJ
msg.s = "This is useful\nPlease add this

"
Re: C like escape sequenses for strings.
Posted: Thu Feb 01, 2007 10:55 pm
by Joakim Christiansen
Tipperton wrote:That way we could do something like
instead of having to do
Code: Select all
msg.s = "Hello" + Chr(13) + Chr(10) + "There!"
Just do like me!
Posted: Thu Feb 01, 2007 10:55 pm
by Trond
No I don't want it.
Code: Select all
msg.s = "Hello" + #CRLF$ + "There!"
Posted: Thu Feb 01, 2007 11:02 pm
by SCRJ
Maybe as a compiler option?
Posted: Thu Feb 01, 2007 11:03 pm
by Clutch
Trond wrote:No I don't want it.
Agreed.
Posted: Thu Feb 01, 2007 11:10 pm
by Trond
SCRJ wrote:Maybe as a compiler option?
That's even worse! It should be EnableEscape and DisableEscape in the source file.
Posted: Fri Feb 02, 2007 12:10 am
by Flype
I must say that sometimes escape sequences are useful.
but a simple procedure do the trick.
pb team might include this function as an optimized one - something like that :
String$ = EscapeString(EscapedString$)
Code: Select all
Procedure.s EscapeString(string.s) ; purebasic function (in string library)
string = ReplaceString(string, "\\", "\")
string = ReplaceString(string, "\t", #TAB$)
string = ReplaceString(string, "\n", #CRLF$)
ProcedureReturn string
EndProcedure
Macro esc(string) ; user defined
EscapeString(string)
EndMacro
MessageRequester("", esc("*\tHello\t\t*\n*\tThere!\t\t*"))
MessageRequester("", esc("C:\\Program Files\\PureBasic\\"))
Posted: Fri Feb 02, 2007 8:16 am
by Chrono Syndrome
2Flype: Khe-khm... Try this: "\\no problems ?"