Is AHK v2 better than v1?
Is AHK v2 better than v1?
I barely used this application, so I'm curious as to which one I should be using to make some scripts for older games, which version be better for this?
Re: Is AHK v2 better than v1?
Yes, v2 is much better than v1. Not only is it the version that will continue to be maintained, it eliminates most of the confusion that made v1 so frustrating for beginners to learn. In general, its syntax and structure are more modern, which results in a much better coding experience.
Re: Is AHK v2 better than v1?
V2 is more consistent and more reliable and will tell you when you have make a syntax mistake. When mistakes are made in V1, it will simply "not work", or produce incorrect result with no explanation why. It will take much longer to track down the cause of errors, even when they are staring you in the face.
I do not recommend v1, especially for AHK rookies. Heck, I've been using it for about 8 years and am still a rookie.
I do not recommend v1, especially for AHK rookies. Heck, I've been using it for about 8 years and am still a rookie.
- CoffeeChaton
- Posts: 44
- Joined: 11 May 2024, 10:50
Re: Is AHK v2 better than v1?
Code: Select all
#Requires AutoHotkey v1.1.33+
; #Warn All, MsgBox
MsgBox, % foo(99) ; just 99 -> "caseEnd" , but not has "ELSE"
MsgBox, % foo(0) ; just "caseEnd", not "ELSE"
MsgBox, % foo(1) ; just "caseEnd", not "ELSE"
MsgBox, % foo(2) ; just "caseEnd", not "ELSE"
MsgBox, % foo(3) ; just "caseEnd", not "ELSE"
MsgBox, % foo(4) ; just "caseEnd", not "ELSE"
;@ahk-neko-format-ignore-start
foo(var1) {
if (var1 = 99), Return "Case99"
MsgBox, % "99"
if (var1 = 0) , Return "caseA"
if (var1 = 1) , Return "caseB"
if (var1 = 2) , Return "caseC"
if (var1 = 3) , Return "caseD"
MsgBox, % "ELSE"
Return "caseEnd"
}
;@ahk-neko-format-ignore-end
When forget to open #warn
if (), XXX or if () XXX, the XXX in if line
v1 will always exceed my imagination.
If you are a beginner, i am recommended to start with v2.
Re: Is AHK v2 better than v1?
nowhere on this page does it say that you can add a comma and then a statement on the same lineCoffeeChaton wrote: ↑24 May 2024, 21:32if (), XXX or if () XXX, the XXX in if line
v1 will always exceed my imagination.
only when using the IfCommand commands can you sometimes do it:
https://www.autohotkey.com/docs/v1/lib/IfEqual.htm
my guess is that the comma is ignored and your code actually works like this:
Code: Select all
foo(var1) {
if (var1 = 99), Return "Case99"
MsgBox, % "99"
if (var1 = 0) , Return "caseA"
if (var1 = 1) , Return "caseB"
if (var1 = 2) , Return "caseC"
if (var1 = 3) , Return "caseD"
MsgBox, % "ELSE"
Return "caseEnd"
}
- CoffeeChaton
- Posts: 44
- Joined: 11 May 2024, 10:50
Re: Is AHK v2 better than v1?
@guest3456
I know these rules, but when I switch from other languages, I often step on rake and forget to enable #warn, there is no prompt, so I have to manually write some static diagnostics in the vscode extension.
I just want to express the syntax of v2, which is more modern, and at the same time have clearer hints for some common mistakes.
tks boiler remind me
I know these rules, but when I switch from other languages, I often step on rake and forget to enable #warn, there is no prompt, so I have to manually write some static diagnostics in the vscode extension.
I just want to express the syntax of v2, which is more modern, and at the same time have clearer hints for some common mistakes.
tks boiler remind me
Last edited by CoffeeChaton on 03 Jun 2024, 11:54, edited 1 time in total.
Re: Is AHK v2 better than v1?
@CoffeeChaton — Do not put img tags around attached images. That results in broken image icons. They are used when you have a URL to an image file.
Return to “Off-topic Discussion”
Who is online
Users browsing this forum: No registered users and 53 guests