Difference between revisions of "ReNamer:Scripts:Initialize"
Jump to navigation
Jump to search
(added nav link) |
m (Text replacement - "<source>" to "<syntaxhighlight lang="pascal">") |
||
Line 5: | Line 5: | ||
== Code == | == Code == | ||
− | < | + | <syntaxhighlight lang="pascal"> |
var | var | ||
Initialized: Boolean; | Initialized: Boolean; |
Revision as of 15:02, 8 February 2017
Pascal Script code gets executed for every file name, but sometimes we need to run some sort of initialization procedure and run it only once. In order to achieve this we need to remember one simple fact: Boolean variables are initialized to "False" before the code is ran for the first time, so we can use this state for our own initialization procedure.
Code
<syntaxhighlight lang="pascal"> var
Initialized: Boolean;
procedure Initialize; begin
Initialized := True; // Initialization code here...
end;
begin
if not Initialized then Initialize; // Main code here...
end. </source>