exitWith – Talk
Jump to navigation
Jump to search
Posted on March 02, 2014 - 09:51
bluechip
Do not use this command to exit a script, function, or any other scope besides a loop, as documented. While the current implementation may exit other scopes, as Killzone_Kid said, it's not part of its specification and may change in the future which will break any scripts that depend on that behavior. That is what the developer was saying in the article.
Also, since this command has some unintended behavior, as Naught pointed out, you should only use this command in the immediate scope of a loop (ie not within nested blocks within the loop), until its implementation is fixed.
This ^^^ note is based on old description of the command that may have been partially incorrect, therefore it is no longer actual Killzone Kid (talk) 00:55, 10 March 2016 (CET)
Lou Montana (talk | contribs) m (Text replacement - "<dt class="note">([^<>]+) " to "<dt class="note">$1</dt> ") |
Lou Montana (talk | contribs) m (Text replacement - " <dd class="notedate">" to " <dt><dt> <dd class="notedate">") |
||
Line 20: | Line 20: | ||
== misleading notes from main page == | == misleading notes from main page == | ||
<dt><dt> | |||
<dd class="notedate">Posted on March 02, 2014 - 09:51</dd> | <dd class="notedate">Posted on March 02, 2014 - 09:51</dd> | ||
<dt class="note">'''[[User:Bluechip_arma|bluechip]]'''</dt> | <dt class="note">'''[[User:Bluechip_arma|bluechip]]'''</dt> |
Revision as of 00:27, 6 April 2021
It seems this command exits the current "scope" (is this the correct term?), rather than the current script file. Is this correct?
Example code, started using execVM:
<stuff> for "_j" from 1 to _value do { <stuff> if (<exit condition>) exitWith {player sideChat "Cancelled"}; }; player sideChat "Complete";
If the exit condition is true, both sideChats are executed. Any comments? Or am I just stating the obvious? :) --Ceeeb 10:04, 7 May 2007 (CEST)
- Seems so, yes. Good find. --raedor 12:33, 7 May 2007 (CEST)
- Yes, it only exits the current level (or "block" or "scope" or whatever). So that behaviour would be expected.
- Do this, for example, and it should become a bit more obvious:
for "_j" from 1 to 10 do
{
player sideChat format["%1",_j];
if (_j==5) exitWith {player sideChat "5 is enough"};
};
player sideChat "Complete";- --Kronzky 16:37, 7 May 2007 (CEST)
misleading notes from main page
This ^^^ note is based on old description of the command that may have been partially incorrect, therefore it is no longer actual Killzone Kid (talk) 00:55, 10 March 2016 (CET)