* subject.Destroy() for i = 1 to alen( this.aObservers ) if ( IsObject( this.aObservers[i] ) ) this.aObservers[i].StopObserving( this ) && might need a parm if the observer && can observer multiple objects this.aObservers[i] = .null. endif endfor * observer.StopObserving( roSubject ) if ( IsObject( this.oSubject ) ) this.oSubject.Detach( this ) endif if ( IsObject( roSubject ) ) roSubject.Detach( this ) endif this.oSubject = .null. *observer.Destroy() this.StopObserving( .null. )>I'd tried the detach method below in the subject object. I was calling the subject.detach from the observer.destroy. It seemed no matter what I did with the subject's zorder it always got destroyed first. I'm not using pemstatus() or getpem().
*subject.detach method >lparameter cObserverName >local cObserverName >for x = 1 to alen(This.aObservers) > if this.aObservers(x).Name = cObserverName > this.aObservers(x) = .null. > endif >next >As it stands, I've duplicated the above code (without the conditional) in a method called DetachAll, and I'm calling it from the form.destroy per Nancy's suggestion. It works, but seems to break from the pattern as defined by G&H.