How can I use the %A_Index% code ?

Get help with using AutoHotkey and its commands and hotkeys
Marcosa1020
Posts: 160
Joined: 23 Sep 2015, 19:15

How can I use the %A_Index% code ?

Post by Marcosa1020 » 17 Sep 2017, 06:14

Hi,

How can I to simplify codeA to codeB ?
Thanks.

Code A:

Code: Select all

If (D6 = 4) and (D7 = 1) and (D2="8D")
{
    GuiControl,1:,card1,1
    Gosub, 8D_S1
    GuiControl,1:,card1,2
    Gosub, 8D_E2
    GuiControl,1:,card1,3
    Gosub, 8D_E3
    GuiControl,1:,card1,4
    Gosub, 8D_E4
    GuiControl,1:,card1,5
    Gosub, 8D_E5
}
Code B:

Code: Select all

If (D6 = 4) and (D7 = 1) and (D2="8D")
    GuiControl,1:,card1,1
    Gosub, 8D_S1
    Loop, 4
{
    GuiControl,1:,card1,1+%A_Index% ; error
    Gosub, 8D_E1+%A_Index% ; error
}

User avatar
boiler
Posts: 6628
Joined: 21 Dec 2014, 02:44

Re: How can I use the %A_Index% code ?

Post by boiler » 17 Sep 2017, 07:01

Code: Select all

If (D6 = 4) and (D7 = 1) and (D2="8D")
{
    GuiControl,1:,card1,1
    Gosub, 8D_S1
    Loop, 4
    {
        GuiControl,1:,card1,% A_Index + 1
        Gosub, % "8D_E" A_Index + 1
    }
}

Marcosa1020
Posts: 160
Joined: 23 Sep 2015, 19:15

Re: How can I use the %A_Index% code ?

Post by Marcosa1020 » 17 Sep 2017, 07:16

boiler wrote:

Code: Select all

If (D6 = 4) and (D7 = 1) and (D2="8D")
{
    GuiControl,1:,card1,1
    Gosub, 8D_S1
    Loop, 4
    {
        GuiControl,1:,card1,% A_Index + 1
        Gosub, % "8D_E" A_Index + 1
    }
}
Thank you.

Post Reply

Return to “Ask For Help”