Testing if a Form or Browse is Already Open
It is often necessary in an Xbasic program to test if a form or browse window is already open. To do this, use the IS_OBJECT() function. For example, the following command tests if a form called Customers is already open. If not, it opens the form. If it is open, it gives focus to the form.
if (is_object(":customers")) then 'form is open :customers.show()'show the form :customers.activate()'give focus to the form :customers.restore()'restore window size in case 'user minimized window else :form.view("customers") 'open the form end if
The IS_OBJECT() function takes an object pointer or an object name as an argument. The .this property of an object address is used to return an object pointer. All of the following would be valid:
IS_OBJECT(customer.this) IS_OBJECT(:customer.this) IS_OBJECT(":customer") IS_OBJECT("customer")