Difference between revisions of "ReNamer:Pascal Script:Break script execution"

From den4b Wiki
Jump to: navigation, search
(Created page with '{{Template:Expand}}')
 
Line 1: Line 1:
{{Template:Expand}}
+
{{Template:CleanUp}}  
 +
 
 +
Using the exit command breaks the current pass of the script. However it doesn’t stop the script from being executed for the next file in the files table and so on. We encounteer here similar problem as with initialization of variables. Solution is also similar. We will use a boolean to keep track if the main code of the script should be executed or not.
 +
 
 +
<br>var<br>TimeToExit : boolean;
 +
 
 +
begin<br> if not TimeToExit then<br> begin<br> //that’s the block for the main script code<br> if DialogYesNo('Would you like to exit script?') then TimeToExit := true;<br> exit;<br> end;<br>end.
 +
 
 +
So the script is still executed for every file, but it’s main code is executed only until TimeToExit becomes true. After that script keeps starting just to see that it has nothing to do.<br><br>

Revision as of 10:54, 13 August 2009

Template:CleanUp

Using the exit command breaks the current pass of the script. However it doesn’t stop the script from being executed for the next file in the files table and so on. We encounteer here similar problem as with initialization of variables. Solution is also similar. We will use a boolean to keep track if the main code of the script should be executed or not.


var
TimeToExit : boolean;

begin
if not TimeToExit then
begin
//that’s the block for the main script code
if DialogYesNo('Would you like to exit script?') then TimeToExit := true;
exit;
end;
end.

So the script is still executed for every file, but it’s main code is executed only until TimeToExit becomes true. After that script keeps starting just to see that it has nothing to do.