Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

WinWait(hwnd) {

Sleep 1000 ; Check every second.

; Let's break the loop but to do so, we need some sort of global variable...

; We call this global ErrorLevel

global ErrorLevel++

if (ErrorLevel > 6)

return ErrorLevel, ErrorLevel := 0 ; returns 7, resets errorlevel to 0.

if DllCall("IsWindow", "ptr", hwnd)

return hwnd

else

return WinWait(hwnd)

}

In the first version, the function returned the identity (own hwnd), or it never returned. In the second version, it's returning the identity or an ErrorLevel. Try to write a terminating WinWait function that doesn't require an external "counting" variable. You actually can't. So the WinWait "function" isn't really taking one input - it's taking two.

`WinWait(hwnd, ErrorLevel)`

But that's why commands can be very intuitive, after all the command syntax isn't bound by a pair of parenthesis, so when I write `WinWait, hwnd`

, maybe it actually runs `WinWait, hwnd, ErrorLevel`

@nnnik there are functions that terminate and never return as well.

Code: [Select all] [Download] GeSHi © Codebox Plus

Shutdown() {

Shutdown, 1

return "SUCCESS" ; <- ???

}