1. Tomas Beran
  2. PowerBuilder
  3. Thursday, 31 August 2023 18:39 PM UTC

PB2022 R2 2819, this code:

window lw_wnd

string ls_classname

if ( IsNULL( lw_window )) then return

ls_classname = ClassName( lw_window )


 

triggers "Null object reference" at line 4 exception.

Is this correct and expected behavior? Or is it something new in PB2022?

Is there anybody who could check it in PB2021 or older?

Thank you

Tomas Beran Accepted Answer Pending Moderation
  1. Friday, 1 September 2023 11:57 AM UTC
  2. PowerBuilder
  3. # 1

Thank you for testing. So this behavior wasn't been changed in PB2022.

 

Comment
There are no comments made yet.
Arnd Schmidt Accepted Answer Pending Moderation
  1. Thursday, 31 August 2023 19:23 PM UTC
  2. PowerBuilder
  3. # 2

Expected. Same in PB 10.5.

Use IsValid() to check if the window is valid.

window lw_window

string ls_classname

if IsValid( lw_window ) then
   ls_classname = ClassName( lw_window )
else
   return
end if

 

hth

Arnd

Comment
  1. Chris Pollach @Appeon
  2. Thursday, 31 August 2023 20:26 PM UTC
Hi Arnd;

Yes, IsValid should be used and NOT IsNull for that validation check! ;-)

Regards ... Chris
  1. Helpful
There are no comments made yet.
Francisco Martinez @Appeon Accepted Answer Pending Moderation
  1. Thursday, 31 August 2023 19:21 PM UTC
  2. PowerBuilder
  3. # 3

What happens if you use not IsValid(...) instead of IsNull(...)?

AFAIK IsNull(...) checks that the variable contains the explicitly-assigned value NULL. When a variable is declared but not initialized, it's not NULL, it's... uninitialized.

Regards,
Francisco

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.