escape char - semicolon in string?

Discuss the future of the AutoHotkey language
egocarib
Posts: 100
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 (http://lexikos.github.io/v2/docs/misc/EscapeChar.htm) 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")
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: escape char - semicolon in string?

22 Oct 2016, 14:00

If possible in v2, you could change the CommentFlag. In v1.1,
[code]
#CommentFlag @
Msgbox, % "String with ; semicolon" @ this is a comment
[/code]
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.
lexikos
Posts: 9592
Joined: 30 Sep 2013, 04:07
Contact:

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 Development”

Who is online

Users browsing this forum: No registered users and 48 guests