ScriptCore3.iif

From Soldat Community Wiki
Revision as of 16:28, 12 August 2013 by Mighty (talk | contribs) (Example)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
function iif(Condition: Boolean; IfTrue, IfFalse: Variant): Variant
 Condition: TRUE or FALSE value.
 IfTrue: Variable which shall be returned if (Condition) is TRUE
 IfFalse: Variable which shall be returned if (Condition) is FALSE

Description

This function acts the same as a normal IF statement, however it may be used inline.

Example

var
  MyCondition: boolean;
  MyInt: integer;
begin
  MyInt := 5942;
  WriteLn('The condition is currently '+iif(MyCondition,'true','false')); //The condition is currently false
  MyCondition := true;
  WriteLn('The condition is currently '+iif(MyCondition,'true','false')); //The condition is currently true
  WriteLn('The condition is currently '+iif(MyInt > 6000,'true','false')); //The condition is currently false
  MyInt := 8468;
  WriteLn('The condition is currently '+iif(MyInt > 6000,'true','false')); //The condition is currently true
end;