The previous remarks refer to the ordinality of Boolean values, not to the values themselves. In Delphi, Boolean
expressions cannot be equated with integers or reals. Hence, if X is an integer variable, the statement
if X then ...;
generates a compilation error. Casting the variable to a Boolean type is unreliable, but each of the following
alternatives will work.
if X <> 0 then ...; { use longer expression that returns Boolean value }
var OK: Boolean;
...
if X <> 0 then OK := True;
if OK then ...;
Dostları ilə paylaş: