Missing closing quote? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
chinagreenelvis
Posts: 133
Joined: 19 Oct 2015, 16:21

Missing closing quote?

Post by chinagreenelvis » 20 Jan 2022, 20:44

Code: Select all

If (!LoopNumber)
{
	LoopNumber++
	IniList .= "`"" A_LoopField ".lst`": `"All Games`""
}
Else
{
	IniList .= "`, `"" A_LoopField ".lst`": `"" A_LoopField "`""
}
The result is supposed to look something like this:

Code: Select all

"DOSBox.lst": "All Games", "DOSBox_Multi-Disc.lst": "Multi-Disc", "DOSBox_Cross-Platform.lst": "Cross-Platform"
I keep getting told that both lines need a closing quote, but according to my count I'm spot-on. Any help is appreciated.

User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: Missing closing quote?  Topic is solved

Post by boiler » 20 Jan 2022, 20:52

You don’t escape quotes with a backtick character. You escape them with another quote character.

chinagreenelvis
Posts: 133
Joined: 19 Oct 2015, 16:21

Re: Missing closing quote?

Post by chinagreenelvis » 20 Jan 2022, 20:55

Oh, that's weird. Strange. Works now, thanks.

User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: Missing closing quote?

Post by boiler » 20 Jan 2022, 20:58

From the documentation:
Expressions wrote:To include an actual quote-character inside a literal string, specify two consecutive quotes as shown twice in this example: "She said, ""An apple a day.""".

iseahound
Posts: 1444
Joined: 13 Aug 2016, 21:04
Contact:

Re: Missing closing quote?

Post by iseahound » 20 Jan 2022, 21:00

I wouldn't bother with escaping quotes in AutoHotkey, it's more frustration than solution.

Instead

Code: Select all

q := Chr(0x22)
loop parse, % "abc123"
If (A_index & 1 == 1)
{
msgbox % A_Loopfield
	IniList .= q A_LoopField ".lst" q ": " q "All Games" q 
}
Else
{
msgbox % A_Loopfield
	IniList .= ", " q A_LoopField ".lst" q ": " q A_LoopField q
}

MsgBox % inilist

Post Reply

Return to “Ask for Help (v1)”