escape char - semicolon in string?

Discuss the future of the AutoHotkey language
Posts: 99
Joined: 21 May 2015, 18:21

escape char - semicolon in string?

22 Oct 2016, 12:39

Would it be possible to support semicolons inside quotation marks without the need to escape them?

The need for other escape chars ( seems clear to me, but I don't understand the need to escape a semicolon. Perhaps there's a scenario in which it would be ambiguous whether the semicolon is part of the string or an indication of a comment, but I'm having a hard time thinking of such a scenario myself.

Currently, this throws a "missing close-quote" error:

Code: Select all

OutputDebug("String with ; semicolon")
Posts: 3572
Joined: 17 Jul 2016, 01:02

Re: escape char - semicolon in string?

22 Oct 2016, 14:00

If possible in v2, you could change the CommentFlag. In v1.1,
#CommentFlag @
Msgbox, % "String with ; semicolon" @ this is a comment
Edit: As noted by Guest3456 below, #CommentFlag is removed in v2.
Last edited by Helgef on 22 Oct 2016, 14:26, edited 1 time in total.
Posts: 6214
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: escape char - semicolon in string?

22 Oct 2016, 23:05

Comments and continuation lines/sections are pre-processed before everything else. In other words, they are processed before the quote mark is known to be the beginning of a quoted string. However, it's often unnecessary to escape the semicolon because comments cannot be preceded by a non-whitespace character:

Code: Select all

OutputDebug("String with; semicolon")

Return to “AutoHotkey v2 Development”

Who is online

Users browsing this forum: No registered users and 1 guest