Begin...End creates a block of statements. Any other statement that allows entry of a single statement can be used with Begin...End to allow entry of multiple statements. The following is an example of Begin...End
procedure ScriptEvent (var Value : variant);
begin
if Value>10 then
begin
LogInfo('this is the first statement to execute if Value is greater than 10');
LogInfo('this is the second statement to execute if Value is greater than 10');
end;
end;
Normally the See "If" statement only allows one statement to be executed if it results in True. By using the Begin...End block you can group multiple statements together. In the above example both LogInfo code lines will execute only if Value is greater than 10. If this script was re-written without the Begin...End block then the second line will execute regardless of the If statement (this is because only the first statement becomes part of the If statement)
procedure ScriptEvent (var Value : variant);
begin
if Value>10 then
LogInfo('this is the first statement to execute if Value is greater than 10');
LogInfo('this statement will execute regardless of whether Value is greater than 10');
end;
Begin...End blocks can be nested.
Each of the other statements in this section include examples of using them with and without Begin...End blocks.
See "Try...Except" is another form for creating blocks of statements the only difference being it supports error handling.