for..until is already reserved:
Code: Select all
#Requires AutoHotkey v2
arr:=['John','Smith','Micheara']
for x in arr{
if x=='Smith'{
MsgBox('I found Smith!')
break
}
} until (x=='John')
MsgBox('I found John!')
I do wish that
for...else would apply not for loops without any iterations, but for loops that make it to the end without breaking: that is, the same behavior as your example. That would break backwards compatibility though
I don't think I've ever had the need for
Loop..Until{}. It might be a rare good use-case for
GoTo:
Code: Select all
arr:=['John','Smith','Micheara']
loop{
if arr[A_Index]=='David'{
MsgBox('I found David!')
goto Common
}
}Until A_index>=3
MsgBox('I can not found David!')
Common:
MsgBox('After finding or not finding')