LMD ScriptPack Guide
If/then/else statement is used to execute code conditionally. The else part can be omit. Here some examples:
if X > 0 then
ShowMessage('X is positive');
if S <> '' then
ShowMessage('S is not empty')
else
ShowMessage('S is empty');
if S <> '' then
begin
ShowMessage('S is not empty');
Result := True;
end
else
ShowMessage('S is empty');
Case statement is another statement for conditional code execution. Unlike Delphi, in PasScript you can specify any expressions in case labels, not only constants. Also, PasScript does not check values uniqueness. Just as in if statement, else part can be omit. Examples:
case x of
0:
ShowMessage('Zero');
1, 3, 5, 7, 9:
ShowMessage('Odd');
2, 4, 6, 8, 10:
ShowMessage('Even');
else
ShowMessage('I''m too young to know numbers greater than 10');
end;
Since any expressions in case labels are allowed, you can also specify, for example, string expressions:
case s of
'True': b := True;
'False': b := False;
else
ShowMessage('Invalid value');
end;
Value ranges are also allowed in case labels:
case x of
1..7:
x := 1;
10, 12, 20..26:
x := 2;
end;