DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

DIAdem 2020 unexpected result for IsObject() on variable set to Nothing

Solved!
Go to solution

Run the script below.  I would expect IsObject() to report FALSE, not TRUE.  I'm pretty sure that was the behavior prior to DIAdem 2020. 

 

Call LogFileDel
Dim oArea
Call LogFileWrite(IsObject(oArea))
Set oArea = Nothing
Call LogFileWrite(IsObject(oArea))  'This should be FALSE
Call LogFileWrite(TypeName(oArea))

'Results:
'FALSE
'TRUE
'Nothing
0 Kudos
Message 1 of 4
(1,594 Views)
Solution
Accepted by topic author markwkiehl

The

IsObject

is part of the VbScript implementation. I assume this never changed with DIAdem version.

So maybe it is because of changing return value of DIAdem API.

If so we would need more information.

 

to check for nothing you need

If oArea Is Nothing Then

 

0 Kudos
Message 2 of 4
(1,543 Views)

Yeah Mark,

 

My memory is that IsObject(Nothing) has always returned TRUE.  In the same way that IsNumeric(Null) has always returned TRUE and IsNumeric("") has always returned TRUE.  The Nothing constant is a denormal constant of type object.  Take Andreas' suggestion with the goofy "If oArea Is Nothing Then" syntax, and that will steer you right.

 

Regards,
Brad Turpin
Principal Technical Support Engineer
National Instruments

0 Kudos
Message 3 of 4
(1,500 Views)

FYI.. I continue to experience inconsistent and unexpected behavior for IsObject and Is Nothing for objects in DIAdem 2020.  I have had to create my own functions to check channel object and others, with excessive error trapping in order to achieve a reliable outcome.  Something has changed, and it varies considerably by context.   

0 Kudos
Message 4 of 4
(1,440 Views)