/* @ICOPY: Interleaved COPY REXX */ /* /* 1 */ /* 2 */ USERS: TSO ISPF EDIT USERS | SCRIPT USERS .ADDRA .ADDRB COPY THE CONTENT OF .ADDRC .ADDRD CONTRIBUTED: 1986/05/10 David McRitchie "The REXX Macros Toolbox" Converted to REXX 1993/05/17 by David McRitchie original author. Can do BEFORE and AFTER at same time, if it makes sense to do so. MEMBER-- VV.MM CREATED- ---MODIFIED--- CURR INIT MOD LASTUSER @ICOPY 01.07 1986/05/10 1991/04/22 16:18 236 238 0 IS03 = @ICOPY 01.04 1986/05/14 1994/04/11 16:34 163 154 0 IS03 == EXAMPLE: @ICOPY .A .B .LINA .LINB @ICOPY .RA .RB MEMBNAM @ICOPY .RA .RB MEMBNAM.ext on PC using SPF/PC DOCUMENTED: IS03.SHARE.TEXT(@ICOPY) IS03.IDREDIT.HELP(@ICOPY) http://members.aol/rexx01/txt/6icopy.txt OPTIONS: LPTR-Dest-Range | ENTIRE (required) Line pointer range. LPTR-Source-Pair | membername | BLANK The source of the material to be copied. The use of BLANK indicate a single blank line. You may not copy a membername named BLANK, nor X, nor NX. AFTER Source lines or membername copied AFTER each dest line. AFTER is the default if BEFORE not specified. BEFORE Source lines or membername copied BEFORE each dest line. X Affects only lines that are EXCLUDED from the display NX Affects only lines that are NOT EXCLUDED from the display. ************************************************************/ Address 'ISREDIT'; 'MACRO (PARMS)'; NOTE = 'LINE_BEFORE .zfirst = NOTELINE ' blank=''; debug=''; entire=''; memb=''; help=''; labc=''; labd=''; labf=''; labl=''; nx=''; x=''; test=''; zedsmsg=''; zedlmsg='' file='';before=''; after=''; iii=0;dataline='DATALINE' insertc=0; /* Collect Parameters */ if parms = '' then do; /* no parameters -- default to a test*/ test='TEST'; labf = '.ZFIRST'; labl = '.ZLAST'; BLANK = 'BLANK' after='AFTER'; signal start; end do iii = 1 to 8; token = word(parms,iii) if token = '' then leave token = translate(token); tokenx = ' '||token||' ' i = pos(tokenx,' ALL NEXT FIRST LAST PREV RIGHT ') if i \= 0 then do; zedsmsg = token 'invalid, RC=8' zedlmsg = token 'not allowed ALL NEXT FIRST LAST PREV RIGHT' call reporter 042; exit 8 end; j = pos(tokenx,' AFTER BEFORE BLANK DEBUG ENTIRE HELP NX TEST X ') if j \= 0 then do; string = token ' = '''token'''' interpret string iterate iii end; if substr(token,1,1) = '.' then do select when labf = '' then labf = token when labl = '' then labl = token when labc = '' then labc = token when labd = '' then labd = token otherwise zedsmsg = '.LABEL RC=8' zedlmsg = 'too many labels --' labf labl labc labd token call reporter exit 8 end /* select */ iterate iii end if file <> '' then do; zedsmsg = 'multi files' token file zedlmsg = 'attempt to use multiple members/files, limit is one' call reporter 053; exit 8 end; file = token end iii fini0: nop if labl = '' then do; zedsmsg = '.labels rc=8' zedlmsg = 'Label range is required' call reporter 062; exit 8 end; /* Process collected parameters */ start: , '(LABFNO) = LINENUM' labf '(LABLNO) = LINENUM' labl insert.=''; if labd ='' then if file = '' then if blank='' then do; zedsmsg = 'Insert?' zedlmsg = 'Insert cards missing: BLANK | filename | insert range' call reporter 70; blank = 'BLANK'; test='TEST' end; if test = 'TEST' then dataline = 'NOTELINE' if blank = 'BLANK' then do; insert.1 = ' ';insertc=1; end; else if file \= '' then nop else if labd \= '' then do; '(LABCNO) = LINENUM' labc '(LABDNO) = LINENUM' labd insertc = labdno + 1 - labcno if labcno > labdno then do; zedsmsg=labc '>' labd zedlmsg='labels out of order,' zedsmsg call reporter 082; exit 8 end; j=0 do i=labcno to labdno; '(LINE) = line' i j=j+1;insert.j = line /* insertc has already been set */ end; end; if before = '' then if after = '' then after = 'AFTER' usenxt = lablno; xnx = x||nx; /* Process the lines in the selected range */ lup1: nop if usenxt < labfno | usenxt = 0 then do; zedsmsg = 'completed RC=0'; zedlmsg = '@ICOPY completed successfully, RC=0' call reporter 000; exit 0 end i = usenxt usenxt = usenxt - 1 if xnx \= '' then do '(xstatus) = xstatus' i if xnx \= xstatus then signal nxti end if 'AFTER' = after then do if insertc = 0 then 'copy' file 'after' i else do ii = insertc to 1 by -1 x = insert.ii "LINE_AFTER" i "=" DATALINE "(X)" end end if 'BEFORE' = before then do /* usenxt is the previous line should work if usenxt=0*/ if insertc = 0 then 'copy' file 'before' i else do ii = 1 to insertc; x = insert.ii "LINE_BEFORE" i "=" DATALINE "(X)" i = i + 1; end; end nxti: signal lup1 /* usenxt has already been set*/ exit 0 reporter: arg arx; note '(zedsmsg)'; note '(zedlmsg)'; /* ISPEXEC not available on OS2 in SPF2 or SPFPC */ ADDRESS "ISPEXEC" "SETMSG MSG(ISRZ000)" return;