Create the Reference
A reference to the AddressForm is created explicitly in the click event of the Show Address Form button. The reference creates an instance of the AddressForm:
SET_REF com(#AddressForm) to(*create_as #refex2)
After this statement we are in basically the same position as we would have been had we simply used a normal DEFINE_COM without the dynamic reference.
Now that an instance of the AddressForm exists, we can run the methods in it. We invoke u_GetDetails passing in to the AddressForm the employee number anad surname:
INVOKE method(#AddressForm.u_GetDetails) U_WITHEMPNO(#EMPNO) U_WITHSURNAME(#SURNAME)
This method in AddressForm receives the employee number and surname, retrieves address information and then displays the form:
MTHROUTINE name(u_GetDetails)
DEFINE_MAP for(*INPUT) class(#EMPNO) name(#u_WithEMPNO)
DEFINE_MAP for(*INPUT) class(#SURNAME) name(#u_WithSURNAME)
CHANGE field(#EMPNO) to('#U_WITHEMPNO.VALUE')
CHANGE field(#SURNAME) to('#U_WITHSURNAME.VALUE')
IF cond('#EMPNO *NE *BLANKS')
FETCH fields(#ADDRESS1 #ADDRESS2 #ADDRESS3) from_file(PSLMST) with_key(#EMPNO)
ENDIF
INVOKE method(#COM_OWNER.ShowForm)
ENDROUTINE