For each cycle

Post a reply

Confirmation code
Enter the code exactly as it appears. All letters are case insensitive.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: For each cycle

Re: For each cycle

Post by guest3456 » 01 May 2018, 10:13

jekko1976 wrote:ah, with the comma it works.
Ok, thank you very much


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 want

https://autohotkey.com/docs/commands/For.htm

Code: [Select all]GeSHi © Codebox Plus

Array := []
Array[1] := "how"
Array[2] := "are"
Array[3] := "you"
For each, element in Array
{
MsgBox %each% : %element%
}


Code: [Select all]GeSHi © Codebox Plus

Array := []
Array[1] := "how"
Array[2] := "are"
Array[3] := "you"
For foo, bar in Array
{
MsgBox %foo% : %bar%
}

Re: For each cycle

Post by jekko1976 » 27 Apr 2018, 04:37

ah, with the comma it works.
Ok, thank you very much

Re: For each cycle

Post by just me » 27 Apr 2018, 04:00

Code: [Select all]GeSHi © Codebox Plus

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
}

Re: For each cycle

Post by nnnik » 27 Apr 2018, 02:46

Code: [Select all]GeSHi © Codebox Plus

Array := []
Array[1] :=how
Array[2] :=are
Array[3] :=you
For each, element in Array
{
MsgBox % element
}

Re: For each cycle

Post by jekko1976 » 27 Apr 2018, 02:19

i'm not sure about that
For sure there are almost 35 way different to obtain a Foreach cycle but, AFAIK the literal Foreach doesn't exist.

Code: [Select all]GeSHi © Codebox Plus

Array := []
Array[1] :=how
Array[2] :=are
Array[3] :=you
For each element in Array
{
MsgBox, element
}


this code does not compile.

Anyway it's not necessary, of course. It could be useful for who came by php, nothing more.

Google told me that the case has been discussed many years ago
https://autohotkey.com/boards/viewtopic.php?t=4259

Re: For each cycle

Post by swagfag » 26 Apr 2018, 17:07

what do u mean? there is a for each already

For each cycle

Post by jekko1976 » 26 Apr 2018, 14:36

Wouldn't be cool to add the for each cycle, like php, to our beloved autohotkey?

Bye

Top