Tech Tip: How to check common data types are empty
PRODUCT: 4D | VERSION: 20 | PLATFORM: Mac & Win
Published On: January 8, 2024
Some of the most common data types are strings, collections, and objects. It is useful to know how to check if they are empty, especially when verifying method outputs. “Empty” means that they have been explicitly defined, but contain no elements. For example:
var $str : Text var $coll : Collection var $obj : Object $str:="" // empty string $coll:=[] // empty collection $obj:={} // empty object |
These all have various ways to check for emptiness. The following are examples of how to verify for each data type:
If ($str="") // Do something… End if If ($coll.length=0) // Do something… End if If (OB Is empty($obj)) // Do something… End if |