CoffeeChaton / vscode-autohotkey-NekoHelp

autoHotkey-1.1 IntelliSense, format, linters, in vscode https://marketplace.visualstudio.com/items?itemName=cat1122.vscode-autohotkey-neko-help

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[feat] support `IFxxxx` (command-like If statements)

CoffeeChaton opened this issue · comments

doc

https://www.autohotkey.com/docs/v1/lib/IfEqual.htm#Remarks
Note that command-like If statements allow a command or command-like control flow statement to be written on the same line, but mispelled command names are treated as literal text. In other words, these are valid:

IfEqual, x, 1, Sleep, 1
IfGreater, x, 1, EnvAdd, x, 2

support semantic-highlight

semantic-highlight

support Go to Definition / Find All References

gif

x := "a"
MyVar := "5,3,7,9,1,13,999,-4" ; -4,1,3,5,7,9,13,999

IfInString x, a, Sort, MyVar, F IntegerSort D,
;                               ^^^^^^^^^^^ func after F[ \t]
MsgBox, % "MyVar is`n" MyVar


IntegerSort(a1, a2)
{
    return a1 - a2
}

effect list

https://www.autohotkey.com/docs/v1/Language.htm#if-statement

IfEqual
IfNotEqual
IfLess
IfLessOrEqual
IfGreater
IfGreaterOrEqual

IfInString
IfNotInString

IfExist, D:\ , MsgBox, The drive exists.
IfNotExist

IfWinActive
IfWinNotActive, WinTitle, WinText, ExcludeTitle, ExcludeText, MsgBox, % "the IfWinNotActive"

IfWinExist 
IfWinNotExist, WinTitle, WinText, ExcludeTitle, ExcludeText, MsgBox, % "the IfWinNotExist"

IfMsgBox

TODO

  • format, if has command in the same line, next line not indentation.
  • diagnosis, like IfInString x, a Sort, MyVar , the a and sort miss comma.

Named If statements allow a command to be written on the same line, but mispelled command names are treated as literal text. Such errors may be difficult to detect.

code701

img

https://www.autohotkey.com/docs/v1/lib/IfEqual.htm#Remarks

Note that command-like If statements allow a command or command-like control flow statement to be written on the same line, but mispelled command names are treated as literal text. In other words, these are valid:

; https://www.autohotkey.com/docs/v1/lib/IfEqual.htm#Remarks
#Requires AutoHotkey v1.1.33+
#Warn All, MsgBox

x = 9
IfGreater, x, 1 , x += 2 ; x > 1, but not run x +=2
MsgBox, % "code 701 case`n x is " x ; x = 9
#Requires AutoHotkey v1.1.33+
#Warn All, MsgBox

x = 9
IfGreater, x, 1
    x += 2
MsgBox, % "OK case`n x is " x ; x = 11

code702

c702 vs OK

#Requires AutoHotkey v1.1.33+
#Warn All, MsgBox

Haystack := "abcdefghijklmnopqrs"
IfInString, Haystack, abc  ListVars
;                        ^^^ miss "," and the ahk can not run
MsgBox, % "text"

https://www.autohotkey.com/docs/v1/Language.htm#if-statement
Named If statements allow a command to be written on the same line, but mispelled command names are treated as literal text. Such errors may be difficult to detect.

#Warn All, MsgBox

MsgBox, % "call fnA(0)"
fnA(0) ; "A" -> B -> C

MsgBox, % "call fnA(1)"
fnA(1) ; B -> C

;  miss "," case
MsgBox, % "call fnB(0)"
fnB(0) ;C

MsgBox, % "call fnB(1)"
fnB(1) ;C

fnA(Var) {
    IfEqual, Var, 0, MsgBox "A"
    MsgBox, % "B"

    MsgBox, % "C"
}

fnB(Var) {
    ;      diag    V miss,---> var !== "0 MsgBox "A""
    IfEqual, Var, 0 MsgBox "A"
        MsgBox, % "B"

    MsgBox, % "C"
}

close at v0.0.45