Reusable S_201RSO

LANSA

Reusable S_201RSO
* ===================================================================;
*;
* Component : S_201RSO;
* Type : Reusable Component;
* Ancestor : PRIM_OBJT (Primitive Object);
*;
* Description : Scope(*Shared) example;
*;
* Full Description: This reusable component is used to manage a list;
* of simple text strings in a keyed collection. It has various;
* methods that allow the user to manager a list of text strings.;
*;
* ===================================================================;
;
FUNCTION OPTIONS(*DIRECT);
BEGIN_COM;
;
* This keyed collection stores the Text;
;
DEFINE_COM CLASS(#PRIM_KCOL) NAME(#TEXTC) COLLECTS(#STD_TEXT) KEYEDBY(#STD_NUM);
DEFINE FIELD(#TextCount) REFFLD(#Std_Num);
;
* Events signalled by this routine;
;
DEFINE_EVT NAME(TextAdded);
DEFINE_MAP FOR(*input) CLASS(#Std_Text) NAME(#Text);
DEFINE_MAP FOR(*input) CLASS(#Std_Num) NAME(#EntryNumber);
;
DEFINE_EVT NAME(TextChanged);
DEFINE_MAP FOR(*input) CLASS(#Std_Text) NAME(#Text);
DEFINE_MAP FOR(*input) CLASS(#Std_Num) NAME(#EntryNumber);
;
;
* ===================================================================;
* Add : Adds a new text string to the collection;
* ===================================================================;
;
MTHROUTINE NAME(Add);
DEFINE_MAP FOR(*input) CLASS(#Std_Text) NAME(#Text);
IF COND('#Text.Value *ne *Blanks');
CHANGE FIELD(#TextCount) TO('#TextCount + 1');
SET COM(#TextC<#TextCount>) VALUE(#Text);
SIGNAL EVENT(TextAdded) TEXT(#Text) ENTRYNUMBER(#TextCount);
ENDIF;
ENDROUTINE;
;
* ===================================================================;
* Update : Updates an existing text string in the collection;
* ===================================================================;
;
MTHROUTINE NAME(Update);
DEFINE_MAP FOR(*input) CLASS(#Std_Text) NAME(#Text);
DEFINE_MAP FOR(*input) CLASS(#Std_Num) NAME(#EntryNumber);
IF COND('(#Text.Value *ne *Blanks) and (#EntryNumber.Value <= #TextCount)');
SET COM(#TextC<#EntryNumber.Value>) VALUE(#Text);
SIGNAL EVENT(TextChanged) TEXT(#Text) ENTRYNUMBER(#EntryNumber);
ENDIF;
ENDROUTINE;
;
END_COM