Ask Your Question

How to test for unset global object? [closed]

asked 2012-12-08 11:11:28 +0200

Gaffer gravatar image

I need to create a global BitmapTable object. I want to be tidy and only create the instance I need, so I want to test the variable before I set it. So I do an IsNull() test on it, so that I only set it if I havn't set it before.

However, the IsNUll() test never triggers on my brand new Global object, so the createInstance never happens.

But then, when we get to oBitmaps.hasByName(), this fails because of "Object variable not set".

I am clearly missing some understanding. Why is my global object not null before use? How else should I test whether it is set?

Many thanks


Global oBitMaps
Sub Main
if ( IsNull(oBitmaps) ) then
    rem this branch never executes
    msgbox "Null"
    oBitmaps = oCalcDoc.createInstance( "" )
    msgbox "Not Null"
    rem I have already created my instance of oBitmaps, no need to create another.
end if
if ( oBitmaps.hasByName( "Test" ) ) then rem <<<< Object variable not set!
    rem do something interesting
End if
End Sub

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2015-10-19 12:28:28.815310

1 Answer

Sort by » oldest newest most voted

answered 2012-12-08 13:34:25 +0200

Gaffer gravatar image

updated 2012-12-08 13:35:35 +0200

Found the answer. I want IsEmpty(), not IsNull()

I don't have enough Karma to mark this as an answer :-(

edit flag offensive delete link more

Question Tools


Asked: 2012-12-08 11:11:28 +0200

Seen: 692 times

Last updated: Dec 08 '12