Reusable Part VL_SAM066: Dynamic Drop Downs

LANSA

Reusable Part VL_SAM066: Dynamic Drop Downs
Name: VL_SAM066

Description: The following RDMLX reusable component is used to dynamically create a drop down list.

This reusable component is used by form VL_SAM067.


FUNCTION OPTIONS(*DIRECT);
BEGIN_COM DISPLAYPOSITION(1) HEIGHT(38) LEFT(0) TABPOSITION(1) TOP(0) WIDTH(196);
DEFINE_COM CLASS(#PRIM_GPBX) NAME(#GROUPBOX) CAPTION('Group (width may be changed)') DISPLAYPOSITION(1) HEIGHT(40) HINTSHOW(False) LEFT(0) PARENT(#COM_OWNER) TABPOSITION(1) TABSTOP(False) TOP(0) WIDTH(196);
DEFINE_COM CLASS(#PRIM_KCOL) NAME(#RB) COLLECTS(#PRIM_RDBN) KEYEDBY(#STD_NUM);
DEFINE_COM CLASS(#PRIM_CMBX) NAME(#VLIST) COMBOBOXSTYLE(DropDownList) DISPLAYPOSITION(1) LEFT(5) PARENT(#GROUPBOX) TABPOSITION(1) TOP(14) WIDTH(185);
DEFINE_COM CLASS(#PRIM_CBCL) NAME(#CBCL_1) PARENT(#VLIST) SOURCE(#STD_CODEL) VISIBLE(False) WIDTH(20);
DEFINE_COM CLASS(#PRIM_CBCL) NAME(#CBCL_2) DISPLAYPOSITION(1) PARENT(#VLIST) SOURCE(#STD_DESC) WIDTHTYPE(Remainder);
;
Define_Pty CurrentCode get(*auto #CCode) Set(SetCode);
Define_Pty CurrentCaption get(*Auto #CCaption) ;
Define_Pty GroupCaption set(SetGrpCaption) ;
Define_Pty WidthFactor set(SetWidthFactor) ;
Define_Pty DownFactor set(SetDownFactor) ;
;
DEFINE_COM CLASS(#STD_CODEL) NAME(#CCODE);
DEFINE_COM CLASS(#STD_DESC) NAME(#CCAPTION);
;
Define #TempFld1 Reffld(#Std_Price) ;
;
Define_Evt CodeChanged;
Define_Map *input #Std_CodeL #NewCode ;
Define_Map *input #Std_Desc #NewCaption ;
;
MthRoutine AddItem;
Define_Map *input #Std_CodeL #UseCode ;
Define_Map *input #Std_Desc #UseCaption ;
Change #Std_CodeL #UseCode.Value;
Change #Std_Desc #UseCaption.Value;
Add_Entry #Vlist;
EndRoutine ;
;
PtyRoutine SetGrpCaption;
Define_Map *input #Std_Desc #PropGrp;
Set #GroupBox Caption(#PropGrp.Value);
EndRoutine ;
;
PtyRoutine SetWidthFactor;
Define_Map *input #Std_Price #PropW;
Change #TempFld1 '#GroupBox.Width * #PropW.Value';
Set #Com_Owner Width(#TempFld1) ;
Set #GroupBox Width(#TempFld1) ;
Change #TempFld1 '#TempFld1 - 10';
Set #Vlist Width(#TempFld1) ;
EndRoutine ;
;
PtyRoutine SetDownFactor;
Define_Map *input #Std_Price #PropD;
Change #TempFld1 '#Vlist.DropDownCount * #PropD.Value';
Set #Vlist DropDownCount(#TempFld1) ;
EndRoutine ;
;
PtyRoutine GetCaption;
define_map *Output #Std_Desc #Prop3;
Set #Prop3 Value(#CCaption);
Endroutine ;
;
PtyRoutine GetCode;
define_map *Output #Std_CodeL #Prop2;
Set #Prop2 Value(#CCode);
Endroutine ;
;
PtyRoutine SetCode;
define_map *input #Std_CodeL #Prop1;
selectlist #Vlist;
if '#Std_CodeL = #Prop1.Value';
Set #VList.CurrentItem Focus(True) ;
Set #CCode Value(#Std_CodeL);
Set #CCaption Value(#Std_Desc);
Signal CodeChanged NewCode(#CCode.Value) NewCaption(#CCaption.Value);
Return ;
Endif ;
EndSelect ;
Abort 'Attempt to set code to a value which has not been previously added to drop down' ;
Endroutine ;
;
EvtRoutine Handling(#VList.itemgotfocus) Options(*NoClearMessages *NoClearErrors);
Set #CCode Value(#Std_CodeL);
Set #CCaption Value(#Std_Desc);
Signal CodeChanged NewCode(#CCode.Value) NewCaption(#CCaption.Value);
ENDROUTINE;
;
END_COM ;