</head> <body> <h1>Exit</h1> <p>Exits the <a href="../misc/Threads.htm">current thread</a> or (if the script is not <a href="_Persistent.htm">persistent</a>) the entire script.</p> <pre class="Syntax"><span class="func">Exit</span> <span class="optional">, ExitCode</span></pre> <h2 id="Parameters">Parâmetros</h2> <dl> <dt>ExitCode</dt> <dd><p>An integer between -2147483648 and 2147483647 (can be an <a href="../Variables.htm#Expressions">expression</a>) that is returned to its caller when the script exits. This code is accessible to any program that spawned the script, such as another script (via RunWait) or a batch (.bat) file. If omitted, <em>ExitCode</em> defaults to zero. Zero is traditionally used to indicate success.</p></dd> </dl> <h2 id="Remarks">Remarks</h2> <p>If the script is not <a href="_Persistent.htm">persistent</a>, Exit will attempt to terminate the entire script as though <a href="ExitApp.htm">ExitApp</a> was called.</p> <p>If the script is not terminated, the Exit command terminates the <a href="../misc/Threads.htm">current thread</a>. In other words, the stack of subroutines called directly or indirectly by a <a href="Menu.htm">menu</a>, <a href="SetTimer.htm">timer</a>, or <a href="../Hotkeys.htm">hotkey</a> subroutine will all be returned from as though a <a href="Return.htm">Return</a> were immediately encountered in each. If used directly inside such a subroutine -- rather than in one of the subroutines called indirectly by it -- Exit is equivalent to <a href="Return.htm">Return</a>.</p> <p>Use <a href="ExitApp.htm">ExitApp</a> to completely terminate a script that is <a href="_Persistent.htm">persistent</a>.</p> <h2 id="Related">Tópicos relacionados</h2> <p><a href="ExitApp.htm">ExitApp</a>, <a href="OnExit.htm#function">OnExit()</a>, <a href="OnExit.htm#command">OnExit</a>, <a href="../Functions.htm">Functions</a>, <a href="Gosub.htm">Gosub</a>, <a href="Return.htm">Return</a>, <a href="../misc/Threads.htm">Threads</a>, <a href="_Persistent.htm">#Persistent</a></p> <h2 id="Examples">Exemplos</h2> <div class="ex" id="ExBasic"> <p><a class="ex_number" href="#ExBasic"></a> In this example, the Exit command terminates the Sub2 subroutine as well as the calling subroutine.</p> <pre>#z:: Gosub, Sub2 MsgBox, This MsgBox will never happen because of the EXIT. return Sub2: Exit <em>; Terminate this subroutine as well as the calling subroutine.</em></pre> </div> </body> </html>