if x <> '' then begin
Result := True;
end else
begin
Result := False;
end;
For when the if statement will be executed?
Basic constructs like this behave in Pascal Script the same as in Pascal.
Free Pascal documentation for If..then..else statement says:
The expression between the
ifandthenkeywords must have aBooleanresult type. If the expression evaluates toTruethen the statement following thethenkeyword is executed.If the expression evaluates to
False, then the statement following theelsekeyword is executed, if it is present.
The expression x <> '' means: the (string) variable x not equals an empty string.
So overall, the code does: If x is not an empty string, set Result to True, else set Result to False. Note that Result is a special identifier used to set a return value of a function in which it is used.
Actually, the code can be simplified to a single statement:
Result := (x <> '');
(brackets are for readability only, they are not required)