Page 2 of 2

Posted: Fri Feb 02, 2007 8:29 am
by bembulak
freak wrote:So all filenames must be written like this: "C:\\Program Files\\..." brrr!
You're right. I didn't think about that ...

Posted: Fri Feb 02, 2007 10:12 am
by ts-soft
traumatic wrote: lol no, why do you think that?
oh, is slash, no backslash :oops:
More coffee please :wink:

Posted: Fri Feb 02, 2007 10:48 am
by traumatic
ts-soft wrote:More coffee please :wink:
;)

Posted: Fri Feb 02, 2007 12:09 pm
by ts-soft
Chrono Syndrome wrote:2Flype: Khe-khm... Try this: "\\no problems ?"
i hope this version fix it:

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 ?"))

Posted: Fri Feb 02, 2007 11:40 pm
by gogo
:twisted: Just a question : How do you escape the double-quote (") character ..... This is why it should be done on the compiler side.

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()
Only UNC name must keep the "\\" in front of the computer name. After you can continue with "/"
e.g:

//mycomputer is not valid
\\mycomputer/myshare/folder is valid

Posted: Fri Feb 02, 2007 11:49 pm
by ts-soft
gogo wrote::twisted: 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"
see the code above, is implemented

Posted: Sat Feb 03, 2007 12:07 am
by gogo
:? oops :( I should read the code before posting.

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 :shock:

Posted: Sat Feb 03, 2007 8:20 am
by rsts
Trond wrote:No I don't want it.

Code: Select all

msg.s = "Hello" + #CRLF$ + "There!"
Agreed +1

(however, as long as we're changing the language, there is some cobol syntax I think we should adopt :D

Posted: Mon Feb 05, 2007 9:16 pm
by Tipperton
Trond wrote:

Code: Select all

msg.s = "Hello" + #CRLF$ + "There!"
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.

Posted: Mon Feb 05, 2007 9:38 pm
by ricardo
Tipperton wrote:
Trond wrote:

Code: Select all

msg.s = "Hello" + #CRLF$ + "There!"
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.
#CRLF$ = chr(13) + chr(10)

Its something anyone can do on his own code

#Eof = chr(13) + chr(10)

Is the one i use.

Posted: Mon Feb 05, 2007 9:43 pm
by Trond
Tipperton wrote:
Trond wrote:

Code: Select all

msg.s = "Hello" + #CRLF$ + "There!"
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.
It's predefined. Take a look at the constants tab in the structure viewer.

Posted: Sat Feb 10, 2007 12:06 pm
by Dr. Dri
Tipperton wrote:
Trond wrote:

Code: Select all

msg.s = "Hello" + #CRLF$ + "There!"
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.
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...

Dri

Posted: Sat Feb 10, 2007 12:32 pm
by Trond
Dr. Dri wrote:But you're right there is nothing written about that...Dri
The manual says that the structure viewer allows you to view all constant that are predefined in PureBasic. Those constants are written in the list of constants. Where else should the be written?

Posted: Sat Feb 10, 2007 1:08 pm
by Dr. Dri
The problem is that having the list of constants itself is not enough IMHO
If i see a SOH constant i wont be able to say what it means...

Dri

Escaping "

Posted: Mon May 12, 2008 1:29 pm
by Crusiatus Black
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?