Ooker
Ooker

Reputation: 3032

Why does command not run after SetTimer?

This code shows up the message box:

Msgbox, Hello

SetTimer, CheckTime, 1000 ; updates every 1 second
CheckTime:
Return

But this doesn't:

SetTimer, CheckTime, 1000 ; updates every 1 second
CheckTime:
Return

Msgbox, Hello

Why is that? I don't see anything special on the SetTimer command.

Upvotes: 2

Views: 318

Answers (1)

Fellipe Freire
Fellipe Freire

Reputation: 115

The script stops executing new lines whenever it finds the first Return keyword.

Everything after the first Top Level Return will be ignored as of initial execution, unless it has been called from above lines.

Look at this code piece:

MsgBox, I'll run!!!

MsgBox, Me 2!!!

Gosub, PastReturn

overPastReturn()

MsgBox, Me 5!!!

Return ; This is the first Top Level Return. Code Stops Executing Here.

MsgBox, Not Me!!!

PastReturn:
    MsgBox, Me 3!!!
Return ; This Return Belongs to PastReturn Label.

MsgBox, Not Me 2!!!

overPastReturn(){
    MsgBox, Me 4!!!
}

Upvotes: 2

Related Questions