IfEmpty
The IfEmpty function checks the variant aValue1, and if it is a empty variant variable (it has a vartype equal to 0), then it will return the replacement value of aValue2.
If aValue1 is not empty, then it will return its own value aValue1.
A variable can be forced to empty.
Please also review IfNull, and also the String Function IfBlank.
Declaration: Function IfEmpty( const aValue1, aValue2 : Variant) : Variant;
Several examples are illustrated in the following.
procedure ScriptEvent (var Value : variant);var Emp1, Emp2, Emp3 : variant;begin LogInfo(''); LogInfo('Emp1 = '+IntToStr(VarType(Emp1))); //EMPTY variant variable returns the vartype of 0 Emp2 := 'Winnie The Pooh'; LogInfo(''); LogInfo('1st IfEmpty pass . . .'); Emp3 := IfEmpty(Emp1, 'Param1 is empty'); //Emp1 is EMPTY LogInfo('Emp3 = '+Emp3); //Emp3 is 'Param1 is empty' LogInfo(''); LogInfo('2nd IfEmpty pass . . . '); Emp3 := IfEmpty(Emp1, Emp2 + ' + Piglet!'); //Emp1 is EMPTY LogInfo('Emp2 = '+Emp2); //Emp2 is 'Winnie The Pooh' LogInfo('Emp3 = '+Emp3); //Emp3 is 'Winnie The Pooh + Piglet!' LogInfo(''); LogInfo('3rd IfEmpty pass . . . '); Emp3 := IfEmpty('', 'This is the replacement value.'); //Param1 is empty LogInfo('Emp3 = '+Emp3); //Emp3 is 'This is the replacement value.' LogInfo(''); LogInfo('4th IfEmpty pass . . . '); Emp3 := IfEmpty(' ', 'Param1 is BLANK'); //aVarVar is NULL LogInfo('Emp3 = '+Emp3); //Emp3 is ' ' (a blank)end;