Main Form

Visual LANSA

Main Form

FUNCTION options(*DIRECT)

BEGIN_COM role(*EXTENDS #PRIM_FORM) CAPTION('Main Form') HEIGHT(290) LEFT(318) TOP(128) WIDTH(386)
* When we use REFERENCE(*DYNAMIC) we tell the application that an instance  of the form
* #REFEX2 (referred to as #AddressForm) will be created when  we get round to it, not when this main form is loaded.
* This means that before we can use this new reference, we have to create it using a SET_REF command:
DEFINE_COM class(#REFEX2) name(#AddressForm) reference(*dynamic)
 
DEFINE_COM class(#PRIM_PHBN) name(#PHBN_ADDR) CAPTION('Show Address Form') DISPLAYPOSITION(1) LEFT(248) PARENT(#COM_OWNER) TABPOSITION(1) TOP(16) WIDTH(112)
DEFINE_COM class(#PRIM_STBR) name(#STBR_1) DISPLAYPOSITION(2) HEIGHT(24) LEFT(0) MESSAGEPOSITION(1) PARENT(#COM_OWNER) TABPOSITION(2) TABSTOP(False) TOP(239) WIDTH(378)
DEFINE_COM class(#EMPNO.Visual) name(#EMPNO) DISPLAYPOSITION(3) HEIGHT(18) LEFT(22) MARGINLEFT(100) PARENT(#COM_OWNER) TABPOSITION(3) TOP(21) WIDTH(163)
DEFINE_COM class(#PRIM_GRID) name(#GRID_1) DISPLAYPOSITION(4) HEIGHT(179) LEFT(24) NOTIFICATIONSTYLE(Default) PARENT(#COM_OWNER) SHOWBUTTONSELECTION(False) SHOWSELECTIONHIGHLIGHT(True) TABPOSITION(4) TOP(48) WIDTH(337)
DEFINE_COM class(#PRIM_GDCL) name(#GDCL_1) DISPLAYPOSITION(1) PARENT(#GRID_1) SOURCE(#EMPNO) WIDTH(35)
DEFINE_COM class(#PRIM_GDCL) name(#GDCL_2) DISPLAYPOSITION(2) PARENT(#GRID_1) SOURCE(#SURNAME) WIDTH(27) WIDTHTYPE(Remainder)
 
EVTROUTINE handling(#com_owner.Initialize)
SELECT fields(#GRID_1) from_file(PSLMST)
ADD_ENTRY to_list(#GRID_1)
ENDSELECT
ENDROUTINE
 
EVTROUTINE handling(#PHBN_ADDR.Click)
* Create  an instance of the AddressForm. After this statement we will be in basically the same position as we would have been had
* we simply used a normal DEFINE_COM without the dynamic reference:
SET_REF com(#AddressForm) to(*create_as #refex2)
 
* Now that an instance of the AddressForm exists, we can run the methods in it.  We invoke u_GetDetails passing in the employee
* number and surname:
INVOKE method(#AddressForm.u_GetDetails) U_WITHEMPNO(#EMPNO) U_WITHSURNAME(#SURNAME)
ENDROUTINE
 
* This event signalled from the AddressForm tells this form that it has closed:
EVTROUTINE handling(#AddressForm.u_Detail_form_closed)
* When the instance of the AddressForm closes, remove it from memory by setting the reference to it to*NULL.
* This says remove anything related to AddressForm from memory.  In other words the form itself, the button
* and the fields will all disappear from the system:
SET_REF com(#AddressForm) to(*null)
 
ENDROUTINE
END_COM

 

Ý Source Code for the Dynamic Reference Forms