Code: Select all
for (int i = 120; i <= 250; i++)
Code: Select all
for k, i in [120, 250]
"for" seems to be faster and works better in a loop than if I did the same through "if".
Code: Select all
for (int i = 120; i <= 250; i++)
Code: Select all
for k, i in [120, 250]
Code: Select all
#Persistent
Array := {}
Loop, 300 ;Creating a test object
Array[A_Index] := "Value: " A_Index
_enum := Array._NewEnum()
Loop ;Enumbered until 120
_enum.Next(Key, Value)
Until, Key = 120
While, Key <= 250 ;Enumbered until 250
{
ToolTip,% "Key: " Key " > " Value
Sleep, 100
_enum.Next(Key, Value)
}
Code: Select all
i := 119
While (++i <= 250) {
; do stuff
}
bapl wrote: ↑27 Sep 2022, 02:44Can this be done on AHK?
For example, do something like this, but without entering the entire sequence.Code: Select all
for (int i = 120; i <= 250; i++)
Of course, I can enter from 120 to 250, but this does not suit me.Code: Select all
for k, i in [120, 250]
"for" seems to be faster and works better in a loop than if I did the same through "if".
Code: Select all
while Y:=for(4,10,2) ; Begin, End, Step
MsgBox % Y
while Y:=for(3,9,3) ; Begin, End, Step
MsgBox % Y
while Y:=for(4,1,-1) ; Begin, End, Step
MsgBox % Y
for(Begin,End,Step)
{
static Next, B, E, S, X
if !Next
{
X:=B:=Begin, E:=End, S:=Step, Next:=true
return X
}
if (S>0?((X+=S)>E):((X+=S)<E))
return Next:=false
else
return X
}
Code: Select all
while Y:=for(0,10,2) ; Begin, End, Step
MsgBox % Y
Code: Select all
Loop % ((i:=120)-250)*++i/-i+--i-(--i)
MsgBox % ++i
Code: Select all
Loop % ((i:=120)-250)*++i/-i+i---i--
MsgBox % ++i
malcev wrote: ↑28 Sep 2022, 04:57You have bug hereWith i >=0 You can try such monster (just for funny)Code: Select all
while Y:=for(0,10,2) ; Begin, End, Step MsgBox % Y
Or this one:Code: Select all
Loop % ((i:=120)-250)*++i/-i+--i-(--i) MsgBox % ++i
Code: Select all
Loop % ((i:=120)-250)*++i/-i+i---i-- MsgBox % ++i