Page 1 of 1

Missing comma

Posted: 26 Jan 2023, 17:05
by HugoM
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)

Re: Missing comma

Posted: 26 Jan 2023, 17:20
by mikeyww
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

Re: Missing comma

Posted: 27 Jan 2023, 07:28
by HugoM
Moin,
I see. Thank you for this detailed answer.