Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

A_index for nested loops


  • Please log in to reply
1 reply to this topic
chroner
  • Guests
  • Last active:
  • Joined: --
for a single loop such as

loop,2
{
msgbox,%A_index%
}

will display 1 and then 2.

is there a way to do something similar with nested loops? From what i can see, the %A_index% always 'refers' to the last loop started. Is there a built in way to access the index for a different loop? Basically, fill in the blank:
loop,2
{
    loop,2
    {
     msgbox, %A_index% is the inner loop index
     msgbox, __________ is the outer loop index
     }
}


engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
you must store it manually

loop,2
{
    Bob := A_index
    loop,2
    {
       msgbox, %A_index% is the inner loop index
       msgbox, %Bob% is the outer loop index
     }
}