Page 1 of 1

Single Instance directive not allowing delimiters

Posted: 05 Mar 2018, 17:17
by Delta Pythagorean
Title says it all.
I'm getting this error:
05-03-2018 16.46.png
05-03-2018 16.46.png (4.65 KiB) Viewed 2226 times
I don't know why it says this, and if I remove the delimiter, it will work like normal again. I don't think I understand.
Yes I have read the docs, but nothing comes up about being picky for delimiters.

Re: Single Instance directive not allowing delimiters

Posted: 05 Mar 2018, 17:32
by derz00
It is documented without the comma. Usually it doesn't work to insert characters and not create a bug. I guess it's easier in AHK than in Python though. Likely the comma was remove to be consistent with the command-style syntax.

Re: Single Instance directive not allowing delimiters  Topic is solved

Posted: 05 Mar 2018, 21:26
by guest3456
Delta Pythagorean wrote:Yes I have read the docs, but nothing comes up about being picky for delimiters.
see these docs:
https://autohotkey.com/v2/v2-changes.htm wrote: Removed "command syntax". That is, a "command" is now just a function or method call without parentheses (at the start of a line). That means:

All former commands are now functions (excluding control flow statements).
All functions can be called without parentheses.
All parameters are expressions or output variables, so all text is "quoted".
Parameters are the same regardless of parentheses; i.e. there is no output variable for the return value, so it is discarded if parentheses are omitted.
Normal variable references are never enclosed in percent signs. Use concatenation or format() to include variables in text.
There is no comma between the function name and parameters, so MouseGetPos(, y) = MouseGetPos , y (x is omitted). A space or tab is required for clarity. For consistency, directives also follow the new convention (there must not be a comma between the directive name and parameter).
There is no percent-space prefix to force an expression.
Commands which previously accepted an "input variable" now also accept other expressions.
Method calls are restricted to a plain variable followed by one or more identifiers separated by dots, such as MyVar.MyProperty.MyMethod "String to pass".
and
https://lexikos.github.io/v2/docs/Functions.htm#intro wrote:
Also, a function may be called without storing its return value:

Code: Select all

Add(2, 3)
Add 2, 3  ; Parentheses can be omitted if used at the start of a line.
this change happened in v2-a079:
https://autohotkey.com/boards/viewtopic.php?p=153136#p153136 wrote: v2.0-a079-be5df98

Removed legacy command syntax and %expression% substitution in strings.

That is, a "command" is now just a function or method call which sits at the start of the line, lacks parentheses and discards its return value. Aside from parentheses, commands and functions now share the same syntax.
"command" syntax now looks like this in AHK v2:

Code: Select all

MsgBox "hello world"   ; no comma allowed, and all params are expressions, so literal text must be quoted
i dislike it very much, and happen to think its a controversial change. others might not feel the same. there has been some discussion about it:

https://autohotkey.com/boards/viewtopic ... 37&t=39469
https://autohotkey.com/boards/viewtopic ... 37&t=31139

Re: Single Instance directive not allowing delimiters

Posted: 06 Mar 2018, 04:58
by nnnik
A preprocessor directive is not a command - at least I wouldn't assume an automatic connection between those 2.
My suggestion is it to either clarify the helpfile or allow the leading , for directives.

Re: Single Instance directive not allowing delimiters

Posted: 06 Mar 2018, 08:30
by guest3456
nnnik wrote:A preprocessor directive is not a command - at least I wouldn't assume an automatic connection between those 2.
My suggestion is it to either clarify the helpfile or allow the leading , for directives.
well the quote from v2 changes does specifically mention that it applies to directives

and the SingleInstance help page itself has no comma:

https://lexikos.github.io/v2/docs/comma ... stance.htm

Re: Single Instance directive not allowing delimiters

Posted: 06 Mar 2018, 10:47
by Delta Pythagorean
Thanks for the help and guides, I appreciate it.
This is gonna take some getting used to