Jump to Real's How-to Main page

Check if an object definition exists

For user object or window
ClassDefinition cd_dwo

cd_dwo = FindClassDefinition(as_objectname2check)

IF IsNull(cd_dwo) THEN
   MessageBox("Error", as_objectname2check &
     + " is not present in the present Library List!")
END IF
For datawindow
datastore lds_temp

lds_temp = CREATE datastore
lds_temp.dataobject = as_objectname2check

IF NOT IsValid(lds_temp.Object) THEN
   MessageBox("Error", "The datawindow "&
     + as_objectname2check + " does not exist!")
END IF

In PB8, the new try/catch can be used to detect missing objects.

TRY
open (w_missing_window)
CATCH (runtimeerror EX)
  MessageBox("Error","Window missing....")
  RETURN -1
END TRY

If you find this article useful, consider making a small donation
to show your supportfor this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2005
[ home ]