Unmatched double quotes

Just starting out? Need help? Post your questions and find answers here.
AZJIO
Addict
Addict
Posts: 2225
Joined: Sun May 14, 2017 1:48 am

Unmatched double quotes

Post by AZJIO »

I get the error "Unmatched double quotes"

Code: Select all

#File = 0
If CreateFile(#File, "_TOC.hhc", #PB_Ascii)
		WriteStringN(#File, ~"\"><param name=\"Local\" value=\"html\\" +  "name" +
		                   ~"\"></OBJECT>")
	CloseFile(#File)
EndIf
If I do it in one line, then everything is fine. But I have long lines, so I do on the next line. I can make a new WriteString()
Axolotl
Addict
Addict
Posts: 872
Joined: Wed Dec 31, 2008 3:36 pm

Re: Unmatched double quotes

Post by Axolotl »

Maybe this is the problem?

Code: Select all

html\\" 
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
Marc56us
Addict
Addict
Posts: 1600
Joined: Sat Feb 08, 2014 3:26 pm

Re: Unmatched double quotes

Post by Marc56us »

Code: Select all

value=\"html\""
:wink:

Code: Select all

#File = 0
If CreateFile(#File, "_TOC.hhc", #PB_Ascii)
    WriteStringN(#File, ~"\"><param name=\"Local\" value=\"html\"" +  "name" +
                        ~"\"></OBJECT>")
    CloseFile(#File)
EndIf
AZJIO
Addict
Addict
Posts: 2225
Joined: Sun May 14, 2017 1:48 am

Re: Unmatched double quotes

Post by AZJIO »

Code: Select all

Debug ~"\"><param name=\"Local\" value=\"html\"" +  "name" +
                        ~"\"></OBJECT>"

Code: Select all

"><param name="Local" value="html"name"></OBJECT>
should be like this:

Code: Select all

"><param name="Local" value="html\name"></OBJECT>
User avatar
mk-soft
Always Here
Always Here
Posts: 6320
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Unmatched double quotes

Post by mk-soft »

Remove / Edit ...

Unfortunately there is no UnescaseString with variables yet
Still works with C-Backend ;)

Link: Format string like sprintf...

Code: Select all

name.s = "Local"
value.s = "html\name"
a.s = Format("><param name=\'%s\' value=\'%s\'></OBJECT>", @name, @value)
debug a
Last edited by mk-soft on Thu Aug 15, 2024 11:59 am, edited 1 time in total.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
mk-soft
Always Here
Always Here
Posts: 6320
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Unmatched double quotes

Post by mk-soft »

Compiler problem with multiple lines and literal string
Is probably a limitation because the end of the literal string is found.

Code: Select all

#File = 0
If CreateFile(#File, GetUserDirectory(#PB_Directory_Downloads) + "_TOC.hhc", #PB_Ascii)
		WriteStringN(#File, ~"\"><param name=\"Local\" value=\"html\\" + "name" + ~"\"></OBJECT>")
	CloseFile(#File)
EndIf
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
NicTheQuick
Addict
Addict
Posts: 1527
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Unmatched double quotes

Post by NicTheQuick »

Looks like a bug to me.
This is the shortest way to see the bug:

Code: Select all

Debug ~"\\" +  
	""
And this works fine:

Code: Select all

Debug ~"\\" + ""
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
AZJIO
Addict
Addict
Posts: 2225
Joined: Sun May 14, 2017 1:48 am

Re: Unmatched double quotes

Post by AZJIO »

NicTheQuick wrote: Thu Aug 15, 2024 3:59 pm Looks like a bug to me.
This is the shortest way to see the bug:

Code: Select all

Debug ~"\\" +  
	""
There should be no mistake here. A character that is special must also be escaped. That is, ~"\" is an error because there is no closing quote. In this line, ~"\\" the "\" character escapes the "\" character.
Quin
Addict
Addict
Posts: 1135
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: Unmatched double quotes

Post by Quin »

AZJIO wrote: Thu Aug 15, 2024 4:06 pm
NicTheQuick wrote: Thu Aug 15, 2024 3:59 pm Looks like a bug to me.
This is the shortest way to see the bug:

Code: Select all

Debug ~"\\" +  
	""
There should be no mistake here. A character that is special must also be escaped. That is, ~"\" is an error because there is no closing quote. In this line, ~"\\" the "\" character escapes the "\" character.
There are two \s, the first one escapes the second one, then the quote closes the string.
Post Reply