Industry wrote: ↑21 Jan 2024, 22:08
Thanks for the explanation ... At the end of the day, a stupid space caused this issue. How are users supposed to know that it makes a difference and to watch out for them? None of this is explained in the documentation. Especially coming from v1 where things like this were never an issue. The error message wasn't helping a novice user understand either.
The AHK language is supposed to be easy to pick up and easy to use. None of this was true here.
This is the whole line btw
If (WinGetMinMax("A") = 1) ... not that complex. No reason to believe that it's a completely different interpretation than
If (WinGetMinMax ("A") = 1)
@Industry
Did you read the response I wrote?
Expressions using parentheses can be quite useful in certain situations.
Even if you don't feel the need for them personally, others may still find them necessary.
Code: Select all
; 1.
switch (userDefaultLocaleName:=A_.UserDefaultLocaleName)
{
default: strHello := "Hello"
case "ja-JP": strHello := "こんにちは"
case "ko-KR": strHello := "안녕하세요"
case "zh-CN","zh-SG","zh-HK","zh-MO","zh-TW":
strHello := "你好"
}
Msgbox(strHello, userDefaultLocaleName)
Class A_ ; v2.0
{
static UserDefaultLocaleName { ; "en-US"
get { ; https://learn.microsoft.com/en-us/windows/win32/api/winnls/nf-winnls-getuserdefaultlocalename
static LOCALE_NAME_MAX_LENGTH:=85
lpLocaleName:=Buffer(bufferSize:=LOCALE_NAME_MAX_LENGTH*A_PtrSize, 0)
length:=DllCall("Kernel32\GetUserDefaultLocaleName", "Ptr",lpLocaleName.Ptr, "Int",cchLocaleName:=LOCALE_NAME_MAX_LENGTH, "Int")
return StrGet(lpLocaleName.Ptr, length, "UTF-16")
}
}
}
Code: Select all
; 2.
Msgbox (LOCALE_NAME_MAX_LENGTH:=85
,lpLocaleName:=Buffer(bufferSize:=LOCALE_NAME_MAX_LENGTH*A_PtrSize, 0)
,length:=DllCall("Kernel32\GetUserDefaultLocaleName", "Ptr",lpLocaleName.Ptr, "Int",cchLocaleName:=LOCALE_NAME_MAX_LENGTH, "Int")
,userDefaultLocaleName:=StrGet(lpLocaleName.Ptr, length, "UTF-16")
,userDefaultLocaleName=="ja-JP"?"こんにちは"
:userDefaultLocaleName=="ko-KR"?"안녕하세요"
:userDefaultLocaleName~="^zh"?"你好"
:"Hello"), userDefaultLocaleName
Take a look at the following two pieces of code.
Personally, I prefer the first method, but there are other programmers who prefer the second approach,
and for the latter, the use of parentheses expression with space can be really helpful.
And the fact that you couldn't find the relevant section in the official documentation doesn't mean it doesn't exist.
The relevant explanation is there, and the official documentation is extensive.
Keep in mind that there is no end to learning.
#operators
Function call wrote:
There must be no space between the function name or expression and the open parenthesis which begins the parameter list. For details, see
Function Calls.
#comma
Comma (multi-statement) wrote:
Comma is also used to delimit the parameters of a function call or control flow statement. To include a multi-statement expression in a parameter list, enclose it in an extra set of parentheses. For example, MyFn((x, y)) evaluates both x and y but passes y as the first and only parameter of MyFn.
#legacy-syntax-removed
Legacy Syntax Removed wrote:
All control flow statements which take parameters (currently excluding the two-word Loop statements) support parentheses around their parameter list,
without any space between the name and parenthesis. For example,
return(var). However, these are not functions; for instance,
x := return(y) is not valid.
If and
While already supported this.
#expressions
Expressions wrote:Function calls now permit virtually any sub-expression for specifying which function to call, provided that there is no space or tab before the open-parenthesis of the parameter list.
A programming language should be beginner-friendly, as we were all beginners at some point.
However, that doesn't mean that all documentation and warnings must be in a form that beginners can understand.
It is excessively inefficient and, in some cases, not even possible.
Above all, it is already happening differently than you think.
The official documentation is detailed on almost everything,
and discussions with questions and answers are taking place on the AHK forum, just as you are receiving responses to your questions now.
A programming language is 'a language', a convention for communication among multiple individuals.
While not perfect, there are sufficiently rational reasons for programming languages to adopt such syntax, unlike natural languages.
There will come a time when things you don't currently understand will become clear.
So, don't lose your perspective, but please be open to humbly accepting feedback from others.