Nothing null empty

Hi everbody,

I have two questions con cerning the concept of Lotusscript.

Is there anyone who could explain to me

a) where is the difference between these values

and

b) why are all these different values meaning the same needed?

The explanation in the helpfile is more than insufficient.

Thanks in advance,

Martin

Subject: NULL at field level, NOTHING at object level

Objects created from Classes will have an initial value of NOTHING, before any other initialization or Set operation.

NULL is assigned to fields (or variants) due to errors in lookup etc.

An object having NOTHING can be seen is a normal, while a field having NULL is more likely to be an error.

And as defined in LSCONST.LSS:

Public Const V_EMPTY = 0 ’ Empty variant

Public Const V_NULL = 1 Variant containing Null

Thanks,

Byju Joy

Subject: NOTHING NULL EMPTY

BJ’s answer is technically correct but not as clear as it could be. I would put it this way:

Nothing

All Lotusscript objects - notesdocument, notesuiworkspace and so on - are Nothing until assigned a value, usually with a set statement:

Dim doc as notesdocument ← doc is Nothing

print (doc is nothing) ← prints “True”

set doc = notesdatabase.alldocuments.getfirstdocument ← now doc contains an object

Empty

Variants are Empty until assigned a value. Use IsEmpty(variant) to determine this. I believe there are cases where a variant can remain Empty even after an assignment statement has run, but I can’t think of such a case right now.

Null

Null is a value that may be assigned to a Variant in certain cases. For example if you use ArrayGetIndex to determine if an array contains a certain value, and at what index, the return value is a Long except if the array does not contain the search value at all, in which case the return value is a variant containing Null. Therefor your return value, on the left side of the assignment statement, must be a variant, not a Long:

dim index as variant

index = ArrayGetIndex( somearray, “foo”, 5 )

select case isnull(index)

case true

print “not there”

case false

print "found it at element " & cstr(index)

end select

Null is never assigned to Lotusscript objects such as notesdocument, notessession or any classes you create - this would be a type mismatch.