vbscriptstackstoragerhino3d

How is a variable of type Variant with value Empty represented on the stack?


The following explanation is from the Rhino Developer Docs

Empty

When you declare a variable in VBScript, the variable’s value before the first assignment is undefined, or Empty.

Dim varValue ' Empty value

So basically, Empty says “I am an uninitialized variant.” If you need to detect whether a variable actually is an empty variant and not a string or a number, you can use IsEmpty. Alternatively, you could use TypeName or VarType, but IsEmpty is best.

So Empty is used for declaring variables. If you declare a variable, you reserve storage at the stack, but what is the value of Empty on the Stack?


Solution

  • VBScript variables are of type Variant. A variant represents a value that can change type. In memory, the Variant type is a 16 byte structure.

    If the variable is empty (Empty value), then the vt member (that stores the type of the data referenced by the variable) will have a value of 0x0000 (VT_EMPTY)