Form S_191FA

LANSA

Form S_191FA
*===================================================================;
*;
* Component : S_191FA;
* Type : Form;
* Ancestor : PRIM_FORM (Primitive Form);
*;
* Description : Demonstrate OV_FILE_SERVICE built in function;
*;
* Disclaimer : The following material is supplied as sample material;
* only. No warranty concerning this material or its use;
* in any way whatsoever is expressed or implied.;
*;
* ===================================================================;
;
FUNCTION OPTIONS(*DIRECT);
BEGIN_COM CAPTION('OV_FILE_SERVICE built in function') FORMPOSITION(ScreenCenter) HEIGHT(466) LEFT(294) TOP(98) WIDTH(650);
DEFINE_COM CLASS(#PRIM_GPBX) NAME(#GPBX_1) CAPTION('OV_FILE_SERVICE Arguments') DISPLAYPOSITION(1) HEIGHT(305) LEFT(8) PARENT(#COM_OWNER) TABPOSITION(1) TABSTOP(False) TOP(8) WIDTH(626);
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#EXECUTEBTN) BUTTONDEFAULT(True) CAPTION('Execute Built in function OV_FILE_SERVICE') DISPLAYPOSITION(2) LEFT(200) PARENT(#COM_OWNER) TABPOSITION(2) TOP(320) WIDTH(273);
DEFINE_COM CLASS(#PRIM_GPBX) NAME(#GPBX_2) CAPTION('Returned Values') DISPLAYPOSITION(3) LEFT(8) PARENT(#COM_OWNER) TABPOSITION(3) TABSTOP(False) TOP(352) WIDTH(625);
DEFINE_COM CLASS(#PRIM_GPBX) NAME(#GPBX_3) CAPTION('Argument 2') DISPLAYPOSITION(1) HEIGHT(54) LEFT(24) PARENT(#GPBX_1) TABPOSITION(2) TABSTOP(False) TOP(232) WIDTH(577);
DEFINE_COM CLASS(#PRIM_GPBX) NAME(#GPBX_4) CAPTION('Arguments 1 and 3 ') DISPLAYPOSITION(2) HEIGHT(217) LEFT(23) PARENT(#GPBX_1) TABPOSITION(1) TABSTOP(False) TOP(16) WIDTH(578);
DEFINE_COM CLASS(#PRIM_SPLM) NAME(#SPLM_1);
DEFINE_COM CLASS(#S_191ARG2.Visual) NAME(#S_191ARG2) CAPTION('Directory and/or file:') DISPLAYPOSITION(1) HEIGHT(19) LABELTYPE(Caption) LEFT(16) MARGINLEFT(159) PARENT(#GPBX_3) TABPOSITION(1) TOP(24) WIDTH(529);
DEFINE_COM CLASS(#PRIM_LTVW) NAME(#LTVW_1) DISPLAYPOSITION(1) FULLROWSELECT(True) HEIGHT(164) LEFT(4) PARENT(#GPBX_4) TABPOSITION(2) TABSTOP(False) TOP(13) WIDTH(557);
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_1) CAPTION('Argument 1: File service ') CAPTIONTYPE(Caption) DISPLAYPOSITION(1) PARENT(#LTVW_1) SOURCE(#S_191ARG1) WIDTH(25);
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_2) CAPTION('Argument 3: Parameter to pass') CAPTIONTYPE(Caption) DISPLAYPOSITION(3) PARENT(#LTVW_1) SOURCE(#S_191AR3A) WIDTH(20) WIDTHTYPE(Remainder);
DEFINE_COM CLASS(#S_191AR3B.Visual) NAME(#S_191AR3B) CAPTION('Copy to file:') DISPLAYPOSITION(2) HEIGHT(19) LABELTYPE(Caption) LEFT(16) MARGINLEFT(159) PARENT(#GPBX_4) TABPOSITION(1) TOP(184) VISIBLE(False) WIDTH(529);
DEFINE_COM CLASS(#S_191RET1.Visual) NAME(#S_191RET1) DISPLAYPOSITION(1) HEIGHT(19) LEFT(80) PARENT(#GPBX_2) TABPOSITION(1) TOP(20) WIDTH(185);
DEFINE_COM CLASS(#S_191RET2.Visual) NAME(#S_191RET2) DISPLAYPOSITION(2) HEIGHT(19) LEFT(288) PARENT(#GPBX_2) TABPOSITION(2) TOP(20) WIDTH(286);
DEFINE_COM CLASS(#S_191FB) NAME(#S_191FB);
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_3) CAPTION('Description of service') CAPTIONTYPE(Caption) DISPLAYPOSITION(2) PARENT(#LTVW_1) SOURCE(#S_191ARGD) WIDTH(39);
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#FINDBTN) CAPTION('...') DISPLAYPOSITION(2) HEIGHT(17) LEFT(552) PARENT(#GPBX_3) TABPOSITION(2) TOP(24) VISIBLE(False) WIDTH(17);
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#FINDBTN2) CAPTION('...') DISPLAYPOSITION(3) HEIGHT(17) LEFT(551) PARENT(#GPBX_4) TABPOSITION(3) TOP(184) VISIBLE(False) WIDTH(17);
DEFINE_COM CLASS(#PRIM_STBR) NAME(#STBR_1) DISPLAYPOSITION(4) HEIGHT(25) LAYOUTSTYLE(Flow) LEFT(0) MESSAGEPOSITION(1) PARENT(#COM_OWNER) TABPOSITION(4) TOP(414) WIDTH(642);
define #msgtext *char 132;
;
EVTROUTINE handling(#com_owner.Initialize);
SET #com_owner caption(*component_desc);
;
* set up the list view of user options;
EXECUTE ADD_OPT ('MAKE_DIR' 'Create new directory' ' ');
EXECUTE ADD_OPT ('REMOVE_DIR' 'Delete directory ' ' ');
EXECUTE ADD_OPT ('CHECK_DIR' 'Check if directory exists' ' ');
EXECUTE ADD_OPT ('CHECK_FILE' 'Check if file exists ' ' ');
EXECUTE ADD_OPT ('SET_FILE' 'Make file read-only ' 'READ_ONLY');
EXECUTE ADD_OPT ('SET_FILE' 'Set file properties to Normal ' 'NORMAL');
EXECUTE ADD_OPT ('COPY_FILE' 'Copy file ' 'Copy to file ');
EXECUTE ADD_OPT ('REMOVE_FILE' 'Remove file if not read-only ' ' ');
EXECUTE ADD_OPT ('REMOVE_FILE' 'Remove file' 'FORCE');
EXECUTE ADD_OPT ('GET_DIR' 'Get contents of directory ' 'File suffix (optional)');
;
ENDROUTINE;
;
SUBROUTINE ADD_OPT (#S_191ARG1 #S_191ARGD #S_191AR3A);
* Add entries to list of options for Arguments 1 and 3;
ADD_ENTRY #LTVW_1;
ENDROUTINE;
;
EVTROUTINE HANDLING(#ExecuteBTN.Click);
;
CASE #S_191ARG1;
WHEN '= COPY_FILE';
* the copy to file;
CHANGE #S_191AR3A #S_191AR3B.value;
WHEN '= GET_DIR';
* the optional file extension;
CHANGE #S_191AR3A #S_191AR3B.value;
ENDCASE;
;
IF '#S_191ARG1 *NE GET_DIR';
* Execute the built in function OV_FILE_SERVICE;
USE OV_FILE_SERVICE (#S_191ARG1 #S_191ARG2 #S_191AR3A) (#S_191RET1 #S_191RET2);
ELSE;
* if the user has chosen GET_DIR, use a separate form to display the contents of the directory;
invoke #S_191FB.uShow uDirect(#S_191ARG2) uSuffix(#S_191AR3A);
ENDIF;
;
*show the service performed and the directory/file in a status bar message;
use bconcat ( #S_191arg1 ' ('#S_191ARGD ') has been performed on ' #S_191arg2) (#msgtext);
MESSAGE MSGID(dcm9993) MSGF(dc@m01) MSGdta(#msgtext);
ENDROUTINE;
;
EVTROUTINE HANDLING(#LTVW_1.ItemGotFocus) OPTIONS(*NOCLEARMESSAGES *NOCLEARERRORS);
* Clear return codes when user changes the option;
CHANGE (#S_191RET1 #S_191RET2) *NULL;
;
* show or hide controls depending on options chosen;
CASE #S_191ARG1;
WHEN '= COPY_FILE';
set #S_191AR3B Visible(True) caption('Argument 3: Copy to file');
set com(#FindBtn #FindBtn2) Visible(True);
WHEN '= GET_DIR';
set #S_191AR3B Visible(True) caption('Argument 3: File suffix (optional):');
set com(#FindBtn #FindBtn2) Visible(False);
WHEN ('= CHECK_FILE' '= SET_FILE' '= CHECK_FILE' '= REMOVE_FILE');
set #FindBtn Visible(True);
set com(#S_191AR3B #FindBtn2) Visible(False);
OTHERWISE;
set com(#S_191AR3B #FindBtn #FindBtn2) visible(false);
ENDCASE;
ENDROUTINE;
;
* use OV_FILE_DIALOG to show the file selection dialog to get file name for Argument 2;
EVTROUTINE HANDLING(#FindBtn.Click);
USE BUILTIN(OV_FILE_DIALOG) TO_GET(#S_191ARG2 #S_191RET1);
ENDROUTINE;
;
* use OV_FILE_DIALOG to show the file selection dialog to get Copy To file name;
EVTROUTINE HANDLING(#FindBtn2.Click);
USE BUILTIN(OV_FILE_DIALOG) TO_GET(#S_191AR3B #S_191RET1);
ENDROUTINE;
;
;
END_COM;
;