Single Instance directive not allowing delimiters

Discuss the future of the AutoHotkey language
User avatar
Delta Pythagorean
Posts: 414
Joined: 13 Feb 2017, 13:44
GitHub: DelPyth
Location: Equestria

Single Instance directive not allowing delimiters

05 Mar 2018, 17:17

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 272 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.
User avatar
derz00
Posts: 486
Joined: 02 Feb 2016, 17:54
GitHub: derz00
Location: Middle of the round cube

Re: Single Instance directive not allowing delimiters

05 Mar 2018, 17:32

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.
try it and see
...
guest3456
Posts: 2313
Joined: 09 Oct 2013, 10:31

Re: Single Instance directive not allowing delimiters

05 Mar 2018, 21:26

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] [Download] GeSHi © Codebox Plus

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] [Download] GeSHi © Codebox Plus

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

User avatar
nnnik
Posts: 2907
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: Single Instance directive not allowing delimiters

06 Mar 2018, 04:58

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.
Recommends AHK Studio
guest3456
Posts: 2313
Joined: 09 Oct 2013, 10:31

Re: Single Instance directive not allowing delimiters

06 Mar 2018, 08:30

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

User avatar
Delta Pythagorean
Posts: 414
Joined: 13 Feb 2017, 13:44
GitHub: DelPyth
Location: Equestria

Re: Single Instance directive not allowing delimiters

06 Mar 2018, 10:47

Thanks for the help and guides, I appreciate it.
This is gonna take some getting used to

Return to “AutoHotkey v2 Development”

Who is online

Users browsing this forum: No registered users and 3 guests