Missing comma

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
HugoM
Posts: 37
Joined: 06 Mar 2018, 14:21

Missing comma

Post by HugoM » 26 Jan 2023, 17:05

Hi all,
in this Code I missed a comma. When I run this test the result is catastrophic, Windows plays crazy.

#Warn
arr := [500, 400]
Click(arr[1] , 600) ; o.k.
Click(arr[1] 3) ; Missing comma


Is there any situation where this missing comma makes sense? Or should it not be warned?

(Sorry for my GermEnglish)

User avatar
mikeyww
Posts: 26944
Joined: 09 Sep 2014, 18:38

Re: Missing comma

Post by mikeyww » 26 Jan 2023, 17:20

Yes, the missing comma makes sense when you are building a single expression instead of attempting to create two expressions as different parameters. The documentation shows examples and includes one where the parameters are listed in quotation marks. You would find something similar with other functions.

Remember that functions use expressions rather than literal strings.

Code: Select all

#Requires AutoHotkey v2.0
arr := [5, 4]
gui1 := Gui()
gui1.AddText(, arr[1] 3)
gui1.Show
Since AHK v2 has no commands (just functions, aside from flow control), expressions are used at all times.

Explained: Concatenate
Concatenate. A period (dot) with at least one space or tab on each side is used to combine two items into a single string. You may also omit the period to achieve the same result (except where ambiguous such as x -y, or when the item on the right side has a leading ++ or --). When the dot is omitted, there must be at least one space or tab between the items to be merged.
And for Click:
Options: Specify zero or more of the following components: Coords, WhichButton, ClickCount, DownOrUp, and/or Relative. Separate each component from the next with at least one space, tab, and/or comma (within a string or as separate parameters).
Example

HugoM
Posts: 37
Joined: 06 Mar 2018, 14:21

Re: Missing comma

Post by HugoM » 27 Jan 2023, 07:28

Moin,
I see. Thank you for this detailed answer.

Post Reply

Return to “Ask for Help (v2)”