Source Code for the Collection Programming Example

Visual LANSA

Source Code for the Collection Programming Example

 


* COMPONENT:  STD_FORM


Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Clientheight(261) Clientwidth(545) Height(288) Layoutmanager(#ATLM_1) Left(247) Top(149) Width(553)
 
Define_Com Class(#PRIM_GPBX) Name(#GPBX_1) Caption('Define_Pty *Collection Example') Displayposition(1) Height(225) Left(16) Parent(#COM_OWNER) Tabposition(1) Tabstop(False) Top(16) Width(177)
Define_Com Class(#PRIM_PHBN) Name(#PHBN_1) Caption('One') Displayposition(1) Left(8) Parent(#GPBX_1) Tabposition(5) Top(26)
Define_Com Class(#PRIM_CKBX) Name(#CKBX_1) Caption('Add me') Displayposition(2) Left(96) Parent(#GPBX_1) Tabposition(8) Top(26) Width(73)
Define_Com Class(#PRIM_PHBN) Name(#PHBN_2) Caption('Two') Displayposition(3) Left(8) Parent(#GPBX_1) Tabposition(2) Top(58)
Define_Com Class(#PRIM_CKBX) Name(#CKBX_2) Caption('Add me') Displayposition(4) Left(96) Parent(#GPBX_1) Tabposition(4) Top(58) Width(73)
Define_Com Class(#PRIM_PHBN) Name(#PHBN_3) Caption('Three') Displayposition(5) Left(8) Parent(#GPBX_1) Tabposition(7) Top(90)
Define_Com Class(#PRIM_CKBX) Name(#CKBX_3) Caption('Add me') Displayposition(6) Left(96) Parent(#GPBX_1) Tabposition(10) Top(90) Width(73)
Define_Com Class(#PRIM_PHBN) Name(#PHBN_4) Caption('Four') Displayposition(7) Left(8) Parent(#GPBX_1) Tabposition(1) Top(122)
Define_Com Class(#PRIM_CKBX) Name(#CKBX_4) Caption('Add me') Displayposition(8) Left(96) Parent(#GPBX_1) Tabposition(3) Top(122) Width(73)
Define_Com Class(#PRIM_PHBN) Name(#PHBN_5) Caption('Five') Displayposition(9) Left(8) Parent(#GPBX_1) Tabposition(6) Top(154)
Define_Com Class(#PRIM_CKBX) Name(#CKBX_5) Caption('Add me') Displayposition(10) Left(96) Parent(#GPBX_1) Tabposition(9) Top(154) Width(73)
Define_Com Class(#PRIM_GPBX) Name(#GPBX_3) Caption('Collection') Displayposition(2) Height(217) Left(200) Parent(#COM_OWNER) Tabposition(2) Tabstop(False) Top(24) Width(337)
Define_Com Class(#PRIM_PHBN) Name(#INSERT) Caption('Insert') Displayposition(2) Left(16) Parent(#GPBX_3) Tabposition(2) Top(24) Width(89)
Define_Com Class(#PRIM_PHBN) Name(#REMOVEALL) Caption('Remove All') Displayposition(3) Left(16) Parent(#GPBX_3) Tabposition(3) Top(56) Width(89)
Define_Com Class(#PRIM_PHBN) Name(#ITERATECOLL) Caption('Iterate Collection') Displayposition(4) Left(16) Parent(#GPBX_3) Tabposition(4) Top(88) Width(89)
Define_Com Class(#PRIM_PHBN) Name(#ITERATEREF) Caption('Iterate Reference') Displayposition(5) Left(16) Parent(#GPBX_3) Tabposition(5) Top(120) Width(89)
 
Define_Com Class(#PRIM_GRID) Name(#GRID_1) Captionnoblanklines(True) Displayposition(1) Height(153) Left(120) Parent(#GPBX_3) Showbuttonselection(True) Showselection(True) Showselectionhilight(False) Showsortarrow(True) Tabposition(1) Top(24) Width(193)
Define_Com Class(#PRIM_GDCL) Name(#GDCL_1) Caption('Key') Captiontype(Caption) Displayposition(1) Parent(#GRID_1) Source(#STD_COUNT) Width(50)
Define_Com Class(#PRIM_GDCL) Name(#GDCL_2) Caption('Caption') Captiontype(Caption) Displayposition(2) Parent(#GRID_1) Source(#STD_DESCS) Width(57) Widthtype(Remainder)
Define_Com Class(#PRIM_ATLM) Name(#ATLM_1)
 
Define_Pty Name(Button1) Get(*Reference #Phbn_1)
Define_Pty Name(Button2) Get(*Reference #Phbn_2)
Define_Pty Name(Button3) Get(*Reference #Phbn_3)
Define_Pty Name(Button4) Get(*Reference #Phbn_4)
Define_Pty Name(Button5) Get(*Reference #Phbn_5)
 
Define_Com Class(#PRIM_ACOL<#PRIM_PHBN>) Name(#COLLECTION)
Define_Pty Name(TheCollection) Get(*Collection #Collection)
 
Evtroutine Handling(#INSERT.Click)
If Cond('#ckbx_1.ButtonState = Checked')
Invoke Method(#Collection.Insert) Item(#PHBN_1)
Endif
If Cond('#ckbx_2.ButtonState = Checked')
Invoke Method(#Collection.Insert) Item(#PHBN_2)
Endif
If Cond('#ckbx_3.ButtonState = Checked')
Invoke Method(#Collection.Insert) Item(#PHBN_3)
Endif
If Cond('#ckbx_4.ButtonState = Checked')
Invoke Method(#Collection.Insert) Item(#PHBN_4)
Endif
If Cond('#ckbx_5.ButtonState = Checked')
Invoke Method(#Collection.Insert) Item(#PHBN_5)
Endif
Endroutine
Evtroutine Handling(#REMOVEALL.Click)
Invoke Method(#Collection.RemoveAll)
Endroutine
Evtroutine Handling(#ITERATECOLL.Click)
 
Clr_List Named(#GRID_1)
 
For Each(#Current) In(#Collection) Key(#CurrentKey)
 
Change Field(#STD_COUNT) To('#CurrentKey.Value')
Change Field(#STD_DESCS) To('#Current.Caption')
 
Add_Entry To_List(#GRID_1)
 
Endfor
 
Endroutine
Evtroutine Handling(#ITERATEREF.Click)
 
Clr_List Named(#GRID_1)
 
For Each(#Current) In(#Com_Owner.TheCollection) Key(#CurrentKey)
 
Change Field(#STD_COUNT) To('#CurrentKey.Value')
Change Field(#STD_DESCS) To('#Current.Caption')
 
Add_Entry To_List(#GRID_1)
 
Endfor
 
Endroutine
End_Com

 

Ý Access Collection Items