For each cycle
Posted: 26 Apr 2018, 14:36
Wouldn't be cool to add the for each cycle, like php, to our beloved autohotkey?
Bye
Bye
Let's help each other out
https://www.autohotkey.com/boards/
https://www.autohotkey.com/boards/viewtopic.php?f=13&t=48058
Code: Select all
Array := []
Array[1] :=how
Array[2] :=are
Array[3] :=you
For each element in Array
{
MsgBox, element
}
Code: Select all
Array := []
Array[1] :=how
Array[2] :=are
Array[3] :=you
For each, element in Array
{
MsgBox % element
}
Code: Select all
Array := []
Array[1] := "how" ; if it shall be a literal string
Array[2] := "are"
Array[3] := "you"
For each, element in Array
{
MsgBox %element% ; if it shall be a variable reference
}
realize its just a trick, the syntax is for key,val in object, you are just giving the 'key' variable the name 'each' since you don't care about the 1,2,3 indexes in your array. you can name them whatever you wantjekko1976 wrote:ah, with the comma it works.
Ok, thank you very much
Code: Select all
Array := []
Array[1] := "how"
Array[2] := "are"
Array[3] := "you"
For each, element in Array
{
MsgBox %each% : %element%
}
Code: Select all
Array := []
Array[1] := "how"
Array[2] := "are"
Array[3] := "you"
For foo, bar in Array
{
MsgBox %foo% : %bar%
}