15. July 2024

Much Adoe About Nothing, Null, Empty

Understanding the differences between Null, Empty, and Nothing, and related changes in INOSIM 14

While numbers are initialized with zero (0), and strings with an empty string (“”), there are specific keywords describing objects and variants as uninitialized. Depending on the data type and the Win Wrap Basic (WWB) language variant you are using (WWB-COM or WWB.NET), the keyword to describe an uninitialized or invalid variable can be Null, Empty, or Nothing. Why are these different semantics needed to describe the absence of (valid) data? The following Tip & Trick describes the characteristics and peculiarities of Null, Empty, and Nothing, as well as some changes concerning these between INOSIM 13 and 14.

Empty

Empty describes an uninitialized Variant. This means a variant’s value before its first assignment is empty. As a variant can be of different data types, Empty is both a zero and a zero-length string at the same time.

To test if a variable is Empty, you can use IsEmpty(var), which will return True or False.

In the language variant WWB.NET, the datatype Variant does not exist, so the constant Empty does not exist either. For further differences of WWB-COM and WWB.NET have a look at the Tip &Trick INOSIM 13 – WWB.NET vs. WWB-COM.

Nothing

Nothing is similar to Empty but refers to objects. So basically, Nothing means that an object reference does not refer to an object. To check an object for Nothing it is NOT possible to ask for

If var = Nothing Then

as the equal operator checks for the default property of objects and Nothing does not have a default property. To check for an invalid object use:

If var Is Nothing Then

Null

Null is somewhat different from the other two keywords. Null states that a variable does not contain valid data. A Null is not equal to anything, neither zero, nor zero-length string, nor another Null. Calculations of other expressions with Null will always return a Null:

To check for Null use IsNull(var) in WWB-COM and IsDBNull(var)) in WWB.NET.

Empty Nothing Null
“I am an uninitialized variant.” “I am an object reference that refers to no object.” “I represent a value which is not known.”

Differences in INOSIM Version 14

In INOSIM 13 (and older), elements in Table-Objects, Dictionaries, and alike, that were not assigned a value yet, were Null in WWB-COM and DBNull in WWB.NET. This also applied to Custom Attributes, as the CustomAttributes property is a Dictionary object, too.

In INOSIM 14, these unassigned elements are Empty in WWB-COM or Nothing in WWB.NET. Therefore, checking for empty elements in Table objects and Dictionaries (e.g., Custom Attributes) must be done with the IsEmpty() function (WWB-COM) or by using Is Nothing (WWB.NET).

In addition to the described changes, for Basic properties that have an optional double value, the value was Null (DBNull) in INOSIM 13 (and older) when it was not assigned. In INOSIM 14, this value is Nothing. The following properties are affected by this:

  • Volume property
  • MaxVolume property
  • LowVolume property
  • HighVolume property
  • MaxContents property
  • LowContents property
  • HighContents property
  • Density property
  • Temperature property
  • ExpiryDate property
  • Pressure property
  • MolarMass property
  • HeatCapacity property
  • Color property
  • ComponentProperty property
  • ComponentPropertyT property
  • ComponentPropertyP property
  • InitialAmount property
  • InitialDuration property
  • InitialMassRate property
  • DefaultDensity property
  • ElectricalConductivity property
  • pH property

Download Tip & Trick as PDF

More Questions?

Want to know more about this topic or have another question? Please contact us!

Array ( [posts_per_page] => 3 [post_type] => [category__in] => Array ( [0] => 36 ) [orderby] => rand [order] => ASC )

More Tips & Tricks

Often enough, INOSIM models are maintained by several people. One challenge is to provide everyone involved with the most up-to-date version and to keep them…

6. February 2024

Custom Failure Handling

In INOSIM simulations, custom stochastic unit failures can be utilized to accurately replicate reality in a plant. With the Statistical Analysis Add-on, a large number…

4. October 2019

Applying Table Objects

In INOSIM models, it can be very handy to organize the input for your recipes in Excel Tables, either to have a better overview over…

more

Direct Contact

During local business hours

Germany +49 231 97 00 250