Form VL_SAM085: Favorite/Common Activity Example

LANSA

Form VL_SAM085: Favorite/Common Activity Example
Name: VL_SAM085

Description: The following RDMLX form is used to demonstrate how a desktop favorite / common activity manager can be created.
FUNCTION OPTIONS(*DIRECT);
BEGIN_COM FORMPOSITION(ScreenCenter) FORMSTYLE(StayOnTop) FRAMESTYLE(SizeToolWindow) HEIGHT(94) LEFT(324) TOP(188) WIDTH(539);
DEFINE_COM CLASS(#STD_TEXTS.Visual) NAME(#VISCOMMAND) CAPTION('Description') DISPLAYPOSITION(1) LABELTYPE(Caption) LEFT(2) MARGINLEFT(60) PARENT(#COM_OWNER) TABPOSITION(1) TOP(5) WIDTH(345);
DEFINE_COM CLASS(#STD_TEXTL.Visual) NAME(#VISDESCRIPTION) CAPTION('Command') DISPLAYPOSITION(2) LABELTYPE(Caption) LEFT(2) MARGINLEFT(60) PARENT(#COM_OWNER) TABPOSITION(2) TOP(32) WIDTH(439);
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#BTN_SAVE) CAPTION('Save') DISPLAYPOSITION(3) LEFT(448) PARENT(#COM_OWNER) TABPOSITION(3) TOP(6);
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#BTN_CANCEL) CAPTION('Cancel') DISPLAYPOSITION(4) LEFT(448) PARENT(#COM_OWNER) TABPOSITION(4) TOP(35);
;
Define #StgFile RefflD(#Std_Obj) ;
Define_Evt CmdFileUpdated;
Def_List #CmdList (#Std_Texts #Std_TextL) type(*working) entrys(9999) ;
Define #FileName *char 100;
Define #RetCode *char 2;
;
MthRoutine EditCommand;
Define_Map *input #Std_Texts #Desc;
Define_Map *input #Std_TextL #Cmd;
Define_Map *input #Std_Obj #StoreFile;
Change #StgFile #StoreFile.Value ;
Set #VisCommand Value(#Desc.Value);
Set #VisDescription Value(#Cmd.Value);
Execute CheckSave;
Invoke #Com_Owner.RestoreForm;
Invoke #VisDescription.SetFocus;
Invoke #Com_Owner.ShowModalForm;
EndRoutine ;
;
MthRoutine DeleteCommand;
Define_Map *input #Std_Texts #Desc;
Define_Map *input #Std_Obj #StoreFile;
Change #StgFile #StoreFile.Value ;
;
Clr_LIst #CmdList;
Change #FileName *Part_Dir_Execute;
Use TConcat (#FileName #StgFile '.DAT' ) #FileName;
use builtin(transform_file) with_args(#CmdList #filename t) to_get(#retcode);
;
SelectList #CmdList;
if '#Std_Texts = #Desc.Value';
Dlt_Entry *Current #CmdList;
Leave ;
Endif ;
EndSelect ;
;
use builtin(transform_list) with_args(#CmdList #filename t) to_get(#retcode);
Signal CmdFileUpdated;
;
EndRoutine ;
;
;
MthRoutine NewCommand;
Define_Map *input #Std_Obj #StoreFile;
Change #StgFile #StoreFile.Value ;
Set #VisCommand Value('');
Set #VisDescription Value('');
Execute CheckSave;
Invoke #Com_Owner.RestoreForm;
Invoke #VisCommand.SetFocus;
Invoke #Com_Owner.ShowModalForm;
EndRoutine ;
;
SubRoutine CheckSave;
if '(#VisDescription.Value = *blanks) *or (#VisCommand.Value = *Blanks)';
Set #Btn_Save Enabled(False);
else ;
Set #Btn_Save Enabled(True);
Endif ;
EndRoutine ;
;
EVTROUTINE HANDLING(#BTN_CANCEL.Click);
Invoke #Com_Owner.CloseForm;
ENDROUTINE ;
;
EVTROUTINE HANDLING(#BTN_SAVE.Click);
Clr_LIst #CmdList;
Change #FileName *Part_Dir_Execute;
Use TConcat (#FileName #StgFile '.DAT' ) #FileName;
use builtin(transform_file) with_args(#CmdList #filename t) to_get(#retcode);
;
Change #RetCode Y ;
;
SelectList #CmdList;
if '#Std_Texts = #VisCommand.Value';
Change #Std_TextL #VisDescription.Value;
Upd_Entry #CmdList;
Change #RetCode N ;
Leave ;
Endif ;
EndSelect ;
;
if '#RetCode = Y';
Change #Std_TextS #VisCommand.Value;
Change #Std_TextL #VisDescription.Value;
Add_Entry #CmdList;
Endif ;
;
use builtin(transform_list) with_args(#CmdList #filename t) to_get(#retcode);
;
Invoke #Com_Owner.CloseForm;
Signal CmdFileUpdated;
;
ENDROUTINE ;
;
EVTROUTINE HANDLING(#VisCommand.Changed #VisDescription.Changed) OPTIONS(*NOCLEARMESSAGES *NOCLEARERRORS);
Execute CheckSave;
ENDROUTINE ;
END_COM ;