From Clomosy Docs

No edit summary
No edit summary
Line 1: Line 1:
function VarIsNull(const V: Variant): Boolean;
<div class="alert alert-ligth border border-3 border-primary-subtle rounded-5 p-4 shadow-sm" role="alert">
function VarIsNull(const V: Variant): Boolean;
</div>
 
VarIsNull returns true if the given variant contains the value Null. If the variant contains any other value, the function result is false.<br>
VarIsNull returns true if the given variant contains the value Null. If the variant contains any other value, the function result is false.<br>


Do not confuse a Null variant with an unassigned variant. A Null variant is still assigned, but has the value Null. Unlike unassigned variants, Null variants can be used in expressions and can be converted to other types of variants.<br>
Do not confuse a Null variant with an unassigned variant. A Null variant is still assigned, but has the value Null. Unlike unassigned variants, Null variants can be used in expressions and can be converted to other types of variants.<br>


'''Example:'''<br>
<b>Example</b><br>
:'''Base Syntax'''
<b>TRObject Syntax</b><br>
'''var'''
<pre>
var
   valueInt : Integer;
   valueInt : Integer;
   valueFlt : Float;
   valueFlt : Float;
   valueStr : String;
   valueStr : String;
   valueBool : Boolean;<br>
   valueBool : Boolean;
  '''begin'''<br>
   
   valueInt := nil;
{
   if VarIsNull(valueInt) then
   valueInt = nil;
   if (VarIsNull(valueInt))
   ShowMessage('True');
   ShowMessage('True');
   else
   else
   ShowMessage('False');
   ShowMessage('False');
    
    
   if VarIsNull(valueFlt) then
   if (VarIsNull(valueFlt))
   ShowMessage('True');
   ShowMessage('True');
   else
   else
   ShowMessage('False');   
   ShowMessage('False');   
    
    
   if VarIsNull(valueStr) then
   if (VarIsNull(valueStr))
   ShowMessage('True');
   ShowMessage('True');
   else
   else
   ShowMessage('False');
   ShowMessage('False');
    
    
   valueBool := true;
   valueBool = true;
   if VarIsNull(valueBool) then
   if (VarIsNull(valueBool))
   ShowMessage('True');
   ShowMessage('True');
   else
   else
   ShowMessage('False');<br>
   ShowMessage('False');
'''end;'''
}
</pre>
<b>Base Syntax</b><br>
<pre>
var
  valueInt : Integer;
  valueFlt : Float;
  valueStr : String;
  valueBool : Boolean;


:'''TRObject Syntax'''
begin


  var
valueInt := nil;
    valueInt : Integer;
if VarIsNull(valueInt) then
    valueFlt : Float;
  ShowMessage('True');
    valueStr : String;
else
    valueBool : Boolean;
  ShowMessage('False');
    
    
   {
if VarIsNull(valueFlt) then
   ShowMessage('True');
else
  ShowMessage('False'); 
if VarIsNull(valueStr) then
  ShowMessage('True');
else
  ShowMessage('False');
    
    
  valueInt = nil;
valueBool := true;
  if (VarIsNull(valueInt))
if VarIsNull(valueBool) then
    ShowMessage('True');
  ShowMessage('True');
  else
else
    ShowMessage('False');
  ShowMessage('False');
   
 
  if (VarIsNull(valueFlt))
end;
    ShowMessage('True');
</pre>
  else
 
    ShowMessage('False'); 
<b>Output:</b><br>
 
<div class="alert alert-success" role="alert" data-bs-theme="light">
  if (VarIsNull(valueStr))
False<br>
    ShowMessage('True');
True<br>
  else
True<br>
    ShowMessage('False');
False<br>
   
</div>
  valueBool = true;
  if (VarIsNull(valueBool))
    ShowMessage('True');
  else
    ShowMessage('False');
 
  }


'''Output:'''<br>
<h2> See Also </h2>
False
* [[System_Library#Boolean_Functions | Boolean Functions]]
True
True
False

Revision as of 14:36, 8 October 2024

VarIsNull returns true if the given variant contains the value Null. If the variant contains any other value, the function result is false.

Do not confuse a Null variant with an unassigned variant. A Null variant is still assigned, but has the value Null. Unlike unassigned variants, Null variants can be used in expressions and can be converted to other types of variants.

Example
TRObject Syntax

var
   valueInt : Integer;
   valueFlt : Float;
   valueStr : String;
   valueBool : Boolean;
 
 {
 
  valueInt = nil;
  if (VarIsNull(valueInt))
   ShowMessage('True');
  else
   ShowMessage('False');
   
  if (VarIsNull(valueFlt))
   ShowMessage('True');
  else
   ShowMessage('False');  
  
  if (VarIsNull(valueStr))
   ShowMessage('True');
  else
   ShowMessage('False');
   
  valueBool = true;
  if (VarIsNull(valueBool))
   ShowMessage('True');
  else
   ShowMessage('False');
 
 }

Base Syntax

var
  valueInt : Integer;
  valueFlt : Float;
  valueStr : String;
  valueBool : Boolean;

begin

 valueInt := nil;
 if VarIsNull(valueInt) then
  ShowMessage('True');
 else
  ShowMessage('False');
  
 if VarIsNull(valueFlt) then
  ShowMessage('True');
 else
  ShowMessage('False');  
 
 if VarIsNull(valueStr) then
  ShowMessage('True');
 else
  ShowMessage('False');
  
 valueBool := true;
 if VarIsNull(valueBool) then
  ShowMessage('True');
 else
  ShowMessage('False');

end;

Output:

See Also