quote:
dont forget about scope though...hes calling exit from within a subroutine, and i think the rules state that exit exits the subroutine, not the script
No, I hadn't forgotten about scope. The scope of the subroutine is the scope of the file and/or UDF that it is contained in - it very definately is not the loop.
A subroutine is just script in the same scope which happens to have a label. That's why you can drop into it accidentally if you forget to exit the script.
Personally I agree that converting the subroutine to a UDF and checking @ERROR on return is a much better way of handling the exit, however exiting the file in a subroutine is a valid process.
The fact that it doesn't work is a bug.
Consider this:
code:
; Sample 1
GoSub Sub
; Sample 2
For $i = 1 To 10 "In Loop" ? Exit 0 Next
; Sample 3
For $i = 1 To 10 "In Loop" ? Gosub Sub Next
Exit 0
:Sub
"Subroutine Called" ?
Exit 0
Why do tests 1 and 2 work as expected (script exits) but test 3 continues to execute the loop?