tags:

views:

132

answers:

2

In my PowerBuilder application, the following code segment causes an R0002 error at runtime (a null object is being referenced):

Window w = windows[idx]
IF NOT IsNull( w ) THEN
    MessageBox( "", "ClassName is " + w.GetClassName() ) // This line crashes
END IF

Does anybody know why that is? I was under the impression that IsNull() is specifically meant to test for null values.

+2  A: 

I think these are different kinds of NULL. One is a variable with the value of NULL The other is an object that doesn't exist or hasn't been instantiated.

In the second case, you may want to use isValid().

Bernard Dy
+2  A: 

Use IsValid(w) in order to determine whether an object variable is instantiated —- whether its value is a valid object handle.

Vincent Buck