You're right. I didn't think about that ...freak wrote:So all filenames must be written like this: "C:\\Program Files\\..." brrr!
C like escape sequenses for strings.
oh, is slash, no backslashtraumatic wrote: lol no, why do you think that?

More coffee please

PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

i hope this version fix it:Chrono Syndrome wrote:2Flype: Khe-khm... Try this: "\\no problems ?"
Code: Select all
Procedure.s EscapeString(string.s)
ReplaceString(string, "", "|", 2)
Protected *c.Character = @string
While *c\c <> 0
If *c\c = '|'
*c + SizeOf(Character)
Select *c\c
Case '|' : *c\c = '\'
Case 'a' : *c\c = 7 ; bel
Case 'b' : *c\c = 8 ; backspace
Case 't' : *c\c = 9 ; Tab
Case 'l' : *c\c = 10 ; linefeed
Case 'f' : *c\c = 12 ; formfeed
Case 'r' : *c\c = 13 ; return
Case 'n' ; carriage return
*c - SizeOf(Character)
*c\c = 13
*c + SizeOf(Character)
*c\c = 10
Case 'q' : *c\c = 34 ; dquote
EndSelect
EndIf
*c + SizeOf(Character)
Wend
ProcedureReturn ReplaceString(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\"))
MessageRequester("", esc("\qTest in Dquote\q"))
MessageRequester("", esc( "\\no problems ?"))
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.


A lot of you are scared by strings like this one :
"D:\\PureBasic\\Examples\\Sources\\2DDrawing.pb"
I can admit that it's very boring to use \\ to escape the \ . But, I think that all opponents of the backslash are not aware of the validity of the slash in windows filenme. I just cant remember the last time I typed file paths with backslashes.
This works perfectly on Win32 :
Code: Select all
OpenConsole()
hf = ReadFile(#PB_Any,"D:/PureBasic/Examples/Sources/2DDrawing.pb")
While Eof(hf) = 0
PrintN(ReadString(hf))
Wend
Input()
CloseConsole()
e.g:
//mycomputer is not valid
\\mycomputer/myshare/folder is valid
gogo wrote:Just a question : How do you escape the double-quote (") character ..... This is why it should be done on the compiler side.
Code: Select all
"\q"
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.



But what I want to say is that I cant understand arguments of the anti-backslash lobby. They don't want it because of the windows paths. But they can use the slash. I've seen some jokes with "http:////". We never said that the slash character is the escape character.
If you think that escape character are for insane minds, take a look at regular expressions

Agreed +1Trond wrote:No I don't want it.Code: Select all
msg.s = "Hello" + #CRLF$ + "There!"
(however, as long as we're changing the language, there is some cobol syntax I think we should adopt

Is that #CRFL$ something you defined or pre-defined? And if it's pre-defined, where is the documentation about it and all the other pre-defined things like it? I just did a search of the help file and found nothing.Trond wrote:Code: Select all
msg.s = "Hello" + #CRLF$ + "There!"
#CRLF$ = chr(13) + chr(10)Tipperton wrote:Is that #CRFL$ something you defined or pre-defined? And if it's pre-defined, where is the documentation about it and all the other pre-defined things like it? I just did a search of the help file and found nothing.Trond wrote:Code: Select all
msg.s = "Hello" + #CRLF$ + "There!"
Its something anyone can do on his own code
#Eof = chr(13) + chr(10)
Is the one i use.
It's predefined. Take a look at the constants tab in the structure viewer.Tipperton wrote:Is that #CRFL$ something you defined or pre-defined? And if it's pre-defined, where is the documentation about it and all the other pre-defined things like it? I just did a search of the help file and found nothing.Trond wrote:Code: Select all
msg.s = "Hello" + #CRLF$ + "There!"
Look at the Table with ASCII-Codes their depending figures in purebasic.chm. In the first column there are named ascii codes (NUL to US), you can use those names as constants (#US) to get the ascii code or as string constants (#US$) to get it as a string... But you're right there is nothing written about that...Tipperton wrote:Is that #CRFL$ something you defined or pre-defined? And if it's pre-defined, where is the documentation about it and all the other pre-defined things like it? I just did a search of the help file and found nothing.Trond wrote:Code: Select all
msg.s = "Hello" + #CRLF$ + "There!"
Dri
- Crusiatus Black
- Enthusiast
- Posts: 389
- Joined: Mon May 12, 2008 1:25 pm
- Location: The Netherlands
- Contact:
Escaping "
I have an proceduredll script that also replaces the " character for a binary value, but by using \q is not replacing " for the binary numbers...
How can i escape this character?
How can i escape this character?