quotes

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Rjevsky
User
User
Posts: 23
Joined: Tue Jul 18, 2017 3:41 pm

quotes

Post by Rjevsky »

Maybe this has already been discussed, but I would like to be able to use several kinds of quotes in the code, like AutoIt or PHP.

Code: Select all

Debug(' "Hello Word" ')
Debug(' " '+'Hello Word'+' " ')
Personally, I do not really have this possibility when working with text files and JSON.
I know that you can use Chr (34), but the code becomes very poorly readable.
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: quotes

Post by kenmo »

Hi, I think this has been requested before somewhere.

One problem is that single-quotes already have a syntax meaning in PB, they are used for character values:

Code: Select all

Str.s  = "A"
Char.c = 'A'
Debug Char
Some nicer ways you can use double-quotes now:

Code: Select all

; Escaped strings (PB 5.40+)
Debug ~"\"Hello World\""

; Constant instead of Chr(34)
Debug #DQUOTE$ + "Hello World" + #DQUOTE$

; Shorter constant :)
#DQ$ = #DQUOTE$
Debug #DQ$ + "Hello World" + #DQ$

; Macros
Macro DQ(Text)
  #DQUOTE$ + Text + #DQUOTE$
EndMacro
Macro SDQ(Text)
  ReplaceString(Text, "'", #DQUOTE$)
EndMacro

Debug DQ("Hello World")
Debug SDQ("'Hello World'")
User_Russian
Addict
Addict
Posts: 1443
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: quotes

Post by User_Russian »

Code: Select all

Debug(~"\"Hello Word\"")
User avatar
Bisonte
Addict
Addict
Posts: 1232
Joined: Tue Oct 09, 2007 2:15 am

Re: quotes

Post by Bisonte »

uuhh. Since 5.40 ? oh I think I have to read the changelog more carefully....

And I make my "html" strings with the "old" techniques ;)
PureBasic 6.10 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
Post Reply