Util.IIF

Top  Previous  Next

 

Syntax

function Util.IIF(Condition: boolean; Value1, Value2: variant): variant

 

Alternative Names

ibec_IIF

 

Description

Tests the given Condition and returns Value1 if the condition is found to be TRUE and Value2 if found to be FALSE.

 

See Also

Util.Compare

 

Example

execute UDSBlock

as

declare variable i integer;

begin

  i = 0;

  while (i < 5)

  do begin

  GUI.ShowMessage(Util.IIF(Math.Mod(i, 2) = 0, i || ' is even.', i || ' is odd.'));

  i = i + 1;

     end;

 

  CmpResult = Util.Compare(1, 4);

  if (CmpResult = 1)

  then GUI.ShowMessage('1 is larger than 4');

  else if (CmpResult = -1)

  then GUI.ShowMessage('1 is less than 4');

  else GUI.ShowMessage('1 and 4 are equal');

  

  /* '1' will be converted to 1, result -1 */

  CmpResult = Util.Compare('1', 4);

  

  /* cannot be compared, will result in NULL */

  CmpResult = Util.Compare('This is text', 1000);

end