The first example checks if there is already an instance of the EditToolbar class. If not, one is created.

function attachEditToolbar(formObj)

local t 

t = findinstance("EditToolbar") 

if empty(t) // If null, no instance exists, so 

t = new EditToolbar() // Create one (defined in this file) 

set procedure to program(1) additive // Load this file as procedure file 

endif 

t.attach(formObj) 

The second example finds all instances of the OrderForm class and closes them.

function closeAllOrders()

local f 

f = findinstance("OrderForm") 

do while not empty(f) 

f.close() 

f := findinstance("OrderForm", f) 

enddo