/* REXX | | Name: IMGCOPY (Image Copy) | | Author: David Alcock | dalcock@csw.com | davea@ticnet.com | | Written: 11-FEB-1998 | | Purpose: Copy file SYSUT1 to file SYSUT2 with all bytes written | | Can be used to copy .GIF and .JPG files from a | larger blocksize dataset (like RECFM=VB LRECL=32756) | to a smaller blocksize dataset (like RECFM=FB LRECL=10) | | It should be used with care. It is useful for PC | files which are byte oriented and not record oriented. | | Disclaimer: This REXX exec is FREEWARE. Use at your own risk. It | is provided for your enjoyment and neither David | Alcock or his employer provides any warranty for it's | use. I'd like to hear how it works on your system. */ xgdate = translate(date(),'-',' ') xjdate = substr(date('s'),1,4)"."substr(date('j'),3,3) xtime = time() say "%IMGCOPY - Execution starts - "xgdate" - "xjdate" - "xtime say " " /*--------------------------------------------------------------------- | Ensure our input and output files look okay ------------------------------------------------------------------- */ x = LISTDSI('SYSUT1' 'FILE') if x <> 0 then do say "%IMGCOPY - Error with input SYSUT1 file" say " > "sysmsglvl1 say " > "sysmsglvl2 say " > SYSREASON: "sysreason exit end x = LISTDSI('SYSUT2' 'FILE') if x <> 0 then do say "%IMGCOPY - Error with output SYSUT2 file" say " > "sysmsglvl1 say " > "sysmsglvl2 say " > SYSREASON: "sysreason exit end say "%IMGCOPY - Output SYSUT2 file has LRECL="syslrecl /*--------------------------------------------------------------------- | Read SYSUT1 into a variable called "FILE" that will have a | complete representation of the file ------------------------------------------------------------------- */ "EXECIO * DISKR SYSUT1 (FINIS STEM sysut1_file." file = "" do i = 1 to sysut1_file.0 file = file""sysut1_file.i drop sysut1_file.i end say "%IMGCOPY - Found "sysut1_file.0" lines in input SYSUT1 file" /*--------------------------------------------------------------------- | Create the output file ------------------------------------------------------------------- */ /* | Queue up the records from the input file into the output file | according to the lrecl of the output file. */ address TSO "NEWSTACK" /* Place to put SYSUT2 output */ k = length(file) j = k / syslrecl m = 1 do i = 1 to j record = substr(file,m,syslrecl) queue record m = m + syslrecl k = k - syslrecl end if k <> 0 then do record = left(substr(file,m,k),syslrecl,'00'x) queue record say "%IMGCOPY - Last line had "k" good bytes" say " truncated with "syslrecl-k "binary zero bytes" end say "%IMGCOPY - Wrote "j" output lines to SYSUT2" /* | Write out the SYSUT2 file */ queue '' /* add null line to indicate End-Of-File */ address TSO "EXECIO * DISKW SYSUT2 (FINIS" rc2 = rc address TSO "DELSTACK" if rc2 <> 0 then , say "%IMGCOPY - Error writing to SYSUT2, RC="rc2 /*--------------------------------------------------------------------- | Termination for IMGCOPY ------------------------------------------------------------------- */ theend: xgdate = translate(date(),'-',' ') xjdate = substr(date('s'),1,4)"."substr(date('j'),3,3) xtime = time() say " " say "%IMGCOPY - Execution ends - "xgdate" - "xjdate" - "xtime exit 0