Function SET191H

LANSA

Function SET191H
********** COMMENT(=======================================================);
********** COMMENT(Process ........: SET_191);
********** COMMENT(Function .......: SET191H);
********** COMMENT(Created on .....: 10/10/00 at 14:43:32);
********** COMMENT(Description ....: OV_FILE_SERVICE GET_DIR REMOVE_FILE);
********** COMMENT(Version.........: 1);
**********;
********** COMMENT(This function requests a directory name and then );
********** COMMENT(retrieves and displays its contents. The resulting );
********** COMMENT(contents display can be sorted into various orders.);
********** COMMENT(By double clicking on a displayed file name you );
********** COMMENT(can delete it. File deletion requests must be );
********** COMMENT(confirmed by clicking "Yes" in a message box.);
**********;
********** COMMENT(Disclaimer: The following material is supplied as an);
********** COMMENT(example only. No warranty is expressed or implied.);
**********;
********** COMMENT(Receives: nothing);
**********;
********** COMMENT(=======================================================);
********** COMMENT(Function control options);
FUNCTION OPTIONS(*DIRECT);
DEFINE FIELD(#OV_DIRECT) TYPE(*CHAR) LENGTH(70);
DEFINE FIELD(#OV_PIRECT) REFFLD(#OV_DIRECT);
DEFINE FIELD(#OV_FILTER) TYPE(*CHAR) LENGTH(3) LABEL('Optional Filter');
DEFINE FIELD(#OV_BYTES) TYPE(*DEC) LENGTH(9) DECIMALS(0) LABEL('Total of Sizes') EDIT_CODE(3);
DEFINE FIELD(#OV_OBJECT) TYPE(*DEC) LENGTH(7) DECIMALS(0) LABEL('Total Objects') EDIT_CODE(3);
DEFINE FIELD(#OV_SELECT) TYPE(*DEC) LENGTH(7) DECIMALS(0);
DEF_COND NAME(*OBJECTS) COND('#ov_object *gt 0');
DEFINE FIELD(#OV_RETC) TYPE(*CHAR) LENGTH(2);
DEFINE FIELD(#OV_ERRN) TYPE(*DEC) LENGTH(15) DECIMALS(0);
DEFINE FIELD(#OV_NAME) TYPE(*CHAR) LENGTH(15);
DEFINE FIELD(#OV_PREFIX) TYPE(*CHAR) LENGTH(12);
DEFINE FIELD(#OV_SUFFIX) TYPE(*CHAR) LENGTH(3);
DEFINE FIELD(#OV_DATE) TYPE(*CHAR) LENGTH(8);
DEFINE FIELD(#OV_TIME) TYPE(*CHAR) LENGTH(6);
DEFINE FIELD(#OV_ISDIR) TYPE(*CHAR) LENGTH(1);
DEFINE FIELD(#OV_SIZE) TYPE(*DEC) LENGTH(9) DECIMALS(0) EDIT_CODE(3);
DEFINE FIELD(#OV_PB01) TYPE(*CHAR) LENGTH(30) INPUT_ATR(PB01) DEFAULT('''Order By Name''');
DEFINE FIELD(#OV_PB02) TYPE(*CHAR) LENGTH(30) INPUT_ATR(PB02) DEFAULT('''Order By Suffix''');
DEFINE FIELD(#OV_PB03) TYPE(*CHAR) LENGTH(30) INPUT_ATR(PB03) DEFAULT('''Order By Date/Time''');
DEFINE FIELD(#OV_PB04) TYPE(*CHAR) LENGTH(30) INPUT_ATR(PB04) DEFAULT('''Order By Size''');
DEF_LIST NAME(#WLIST) FIELDS(#OV_NAME #OV_PREFIX #OV_SUFFIX #OV_DATE #OV_TIME #OV_SIZE #OV_ISDIR) TYPE(*WORKING) ENTRYS(5000);
DEF_LIST NAME(#DLIST) FIELDS(#OV_NAME #OV_PREFIX #OV_SUFFIX #OV_DATE #OV_TIME #OV_SIZE #OV_ISDIR) COUNTER(#OV_OBJECT) SEL_ENTRY(#OV_SELECT);
********** COMMENT();
********** COMMENT(Mainline);
********** COMMENT();
DEF_COND NAME(*AS400) COND('*CPUTYPE = AS400');
IF COND(*AS400);
MESSAGE MSGTXT('Not available on iSeries');
MENU;
ELSE;
**********;
BEGIN_LOOP;
CHANGE FIELD(#OV_PIRECT) TO(#OV_DIRECT);
REQUEST FIELDS((#OV_DIRECT *L3 *P2 *NOID) (#OV_FILTER *L4 *P2) (#OV_PB01 *L6 *P2 *NOID *OBJECTS *IOCOND) (#OV_PB02 *L8 *P2 *NOID *OBJECTS *IOCOND) (#OV_PB03 *L6 *P38 *NOID *OBJECTS *IOCOND) (#OV_PB04 *L8 *P38 *NOID *OBJECTS *IOCOND) (#OV_BYTES *L4 *P22 *OUT) (#OV_OBJECT *L4 *P49 *OUT)) BROWSELIST(#DLIST);
CASE OF_FIELD(#IO$KEY);
WHEN VALUE_IS('= B1');
SORT_LIST NAMED(#WLIST) BY_FIELDS(#OV_NAME);
EXECUTE SUBROUTINE(WTOD);
WHEN VALUE_IS('= B2');
SORT_LIST NAMED(#WLIST) BY_FIELDS(#OV_SUFFIX #OV_PREFIX);
EXECUTE SUBROUTINE(WTOD);
WHEN VALUE_IS('= B3');
SORT_LIST NAMED(#WLIST) BY_FIELDS(#OV_DATE #OV_TIME);
EXECUTE SUBROUTINE(WTOD);
WHEN VALUE_IS('= B4');
SORT_LIST NAMED(#WLIST) BY_FIELDS(#OV_SIZE);
EXECUTE SUBROUTINE(WTOD);
OTHERWISE;
IF COND('(#ov_pirect = #ov_direct) *and (#ov_select *gt 0) *and (#ov_object *gt 0)');
EXECUTE SUBROUTINE(DELETE_FIL);
ELSE;
EXECUTE SUBROUTINE(LOAD_DIR);
ENDIF;
ENDCASE;
END_LOOP;
ENDIF;
**********;
SUBROUTINE NAME(LOAD_DIR);
USE BUILTIN(OV_FILE_SERVICE) WITH_ARGS(GET_DIR #OV_DIRECT #OV_FILTER) TO_GET(#OV_RETC #OV_ERRN #WLIST);
IF COND('#OV_RETC = OK');
EXECUTE SUBROUTINE(WTOD);
ELSE;
MESSAGE MSGTXT('ERROR: Unable to list specified directory ');
ENDIF;
ENDROUTINE;
**********;
SUBROUTINE NAME(DELETE_FIL);
DEFINE FIELD(#OV_MBA) TYPE(*CHAR) LENGTH(1);
DEFINE FIELD(#OV_MSG) TYPE(*CHAR) LENGTH(100);
GET_ENTRY NUMBER(#OV_SELECT) FROM_LIST(#DLIST);
IF COND('#ov_isdir = Y');
MESSAGE MSGTXT('Selected object is a directory and cannot be deleted');
ELSE;
USE BUILTIN(BCONCAT) WITH_ARGS('Confirm that file' #OV_NAME 'is to deleted') TO_GET(#OV_MSG);
USE BUILTIN(OV_MESSAGE_BOX) WITH_ARGS(#OV_MSG 'Delete File' YN Q) TO_GET(#OV_MBA);
IF COND('#OV_MBA = Y');
USE BUILTIN(TCONCAT) WITH_ARGS(#OV_DIRECT '\' #OV_NAME) TO_GET(#OV_MSG);
USE BUILTIN(OV_FILE_SERVICE) WITH_ARGS(REMOVE_FILE #OV_MSG) TO_GET(#OV_RETC);
IF COND('#OV_RETC = OK');
EXECUTE SUBROUTINE(LOAD_DIR);
MESSAGE MSGTXT('File successfully deleted');
ELSE;
MESSAGE MSGTXT('ERROR : Attempt to delete file failed');
ENDIF;
ENDIF;
ENDIF;
ENDROUTINE;
**********;
SUBROUTINE NAME(WTOD);
CLR_LIST NAMED(#DLIST);
CHANGE FIELD(#OV_BYTES) TO(0);
SELECTLIST NAMED(#WLIST);
CHANGE FIELD(#OV_BYTES) TO('#ov_bytes + #ov_size');
ADD_ENTRY TO_LIST(#DLIST) WITH_MODE(*DISPLAY);
ENDSELECT;
ENDROUTINE;