/*CUT: Cut portions of file in EDIT (REXX) */ /*CUT: Author: David McRitchie, "The REXX Macros Toolbox" */ /* 1994/04/07 Converted to REXX from specs in use since 1991/12/24 */ /* 1994/06/24 Ability to used numbered CUTDSN## datasets */ /*-------------------------------------------------------------------*/ /* Macro: CUT (CUTR for SPF/PC usage) */ /* Purpose: Cut CC-Range and/or NX lines into */ /* userid.CUTDSN.LIST for later use with PASTE macro. */ /* Companion Macros: APPEND, PASTE -- spf/pc APPENDR, PASTER*/ /* Related Macros: CUTD, CUTDD, REFORMAT */ /*********************************************************************/ /* Highlights: This set of CUT/APPEND/PASTE macros will mark the */ /* changes in the affected file with NOTELINEs. This allows easy */ /* comparison between old material and new material, etc. Some */ /* other versions of CUT/APPEND/PASTE use ISPF variables causing */ /* serious problems with your profile dataset when large files are */ /* copied. This will not happen with these macros, also your data */ /* being in a distinct dataset is protected across logons/crashes. */ /* Written in REXX readily permits later customizations. */ /* Other cut/paste macros: NaSPA 0004, CBT 95, 161, 168, 194, 270 */ /*********************************************************************/ /* THIS EDIT MACRO CLIST AND ITS COMPANIONS */ /* */ /* CUT ---------- ** THIS EDIT MACRO ** ------------ */ /* Take selected lines specified by the user and copy/move */ /* them to a sequential work dataset used later by the paste */ /* command. */ /* APPEND ------- ** COMPANION EDIT MACRO ** ------- */ /* Will append additional information a header will be created, */ /* and information will be appended to your cut dataset. */ /* PASTE -------- ** COMPANION EDIT MACRO ** ------- */ /* Take the output dataset created by cut and move it to */ /* anywhere in the current dataset being edited. */ /* Options of CUT and APPEND (all options are optional) */ /* CC-range -- restrict selected lines -- normal usage */ /* NX -- Include only NX lines within CC-Range or entire range */ /* DOC -- (opt.) document with date/timestamp and source dsn. */ /* NX Copy NX lines, CC-range becomes optional */ /* EDIT edit the paste dataset */ /* ? |HELP Show help information */ /* ## -- 1 or 2 digit number to cut into a different dsn */ /* i.e. userid.CUTDSN##.LIST */ /* Options of PASTE --------------------------------- */ /* KEEP -- Keep work dataset, default is to delete work file */ /* COL(nn),VALUE(xxxx) -- include only lines with value in col nn */ /* (member), paste member from permanent pds PASTE library */ /* ## -- 1 or 2 digit number to paste from a different dsn */ /* i.e. userid.CUTDSN##.LIST */ /* WARNINGS: ----- WARNINGS ------------------------- */ /* The CUT file attributes are based on the original file cut -- */ /* you may lose later information added if the recordsize is */ /* larger than the original -- especially for fixed records. */ /* m or mm line options will alter your dataset by removing */ /* lines. Other cut/paste clists may eat up your profile */ /* dataset, this clist uses a work file and therefore does not */ /* affect your profile. */ /* */ /* EXAMPLE : */ /* CUT USE CC OR MM LINE RANGE, OR C OR M */ /* APPEND USE CC OR MM LINE RANGE, OR C OR M */ /* PASTE USE B OR A LINE RANGE */ /*********************************************************************/ /* NOTE: QWPASTE MUST BE USED WHEN USING PASTE FACILITIES OF */ /* MVS/QUICKREF 3.2 INVOKED VIA QW. */ /*********************************************************************/ /* */ address "ISREDIT";"MACRO (TOKEN) NOPROCESS" possible=0; copied=0;other="";CUTDSNnn="CUTDSN" token = ' 'translate(token)' ' i=pos(' HELP ',token); if i=0 then i=pos('?',TOKEN); if i \= 0 then do; address "TSO" "CLIST CUT HELP"; exit 1;end; i =pos(' NX ',token) if i \= 0 then do;nxopt=1; token = substr(token,1,i-1)||substr(token,i+3) end; else nxopt = 0 i =pos(' DOC ',token) if i \= 0 then do;docopt=1; token = substr(token,1,i-1)||substr(token,i+4) end; else docopt = 0 i =pos(' EDIT ',token) if i \= 0 then do;editopt=1; token = substr(token,1,i)||substr(token,i+6) end; else editopt = 0 remaining = strip(token) if remaining \= "" then do if datatype(remaining,'N') = 1 then do other = remaining + 0; remaining="" CUTDSNnn = CUTDSNnn||other end end if remaining \= "" then do ZEDSMSG = "unknown" remaining ZEDLMSG = remaining "-- unknown to CUT/APPEND/PASTE" ADDRESS "ISPEXEC" "SETMSG MSG(ISRZ000)" end zedsmsg = '**';zedlmsg='**' "(rowx,colx) = cursor" qcnt = 0 q.="" ADDRESS 'ISREDIT' '(DSN) = DATASET' ADDRESS 'ISREDIT' '(MEMBER) = MEMBER' parse version v1 v2 v3 v4 v5 if v1 = "REXXSAA" then do /* obtain membername */ do i = 1 to 8 parse var member left '\' right if right \= "" then member = right end parse var member member '.' right dochdr = dsn end if member = "" then dochdr="-----" dsn else dochdr=strip(dsn)"("strip(member)")" first = 99999999; last = 00000000; Address "ISPEXEC" "CONTROL ERRORS RETURN" "PROCESS RANGE C M" rcx=rc "(RANGE) = RANGE_CMD" Address "ISPEXEC" "CONTROL ERRORS CANCEL" if rcx > 4 then do ZEDSMSG = ZERRSM ZEDLMSG = ZERRMSG ZERRLM "RC="rcx Address "ISPEXEC" "SETMSG MSG(ISRZ000)" exit rcx end LABF = ".ZFRANGE" LABL = ".ZLRANGE" "(first) = linenum .zfrange" "(last) = linenum .zlrange" if docopt = 1 then qcnt = 2 /* will fill in later*/ do i = first to last possible= possible+1 if nxopt = 1 then do address "ISREDIT" "(xstatus) = xstatus" i if xstatus \= "NX" then iterate i end address "ISREDIT" "(line) = line" i qcnt=qcnt+1; q.qcnt = line copied = copied + 1 end q.0 = qcnt if docopt = 1 then do if nxopt = 1 then q.1 = left('.***',40) "Copied" copied "of" possible else q.1 = '.***' q.2 = '.***' date("U") time() dochdr '-- Lines', strip(first,'l','0')'-'strip(last,'l','0') end if v1 = "REXX370" then call mainframe if v1 = "REXXSAA" then call PComputer if range = "M" then do; address "ISREDIT" "delete" first last var1=first-1; var2=last-first+1; "line_after" var1 "= noteline """time() "CUT --", var2 "lines removed and placed into "CUTDSNnn"""" "line_before .zfirst = msgline """time() "CUT --", var2 "lines removed and placed into "CUTDSNnn"""" end /* would be nicer to report the visible line number */ if range = "C" then do; address "ISREDIT" "line_before" first "= noteline """time() "start CUT --" copied, "lines" "copied to "CUTDSNnn", lines("||, strip(first,"l","0")"-"strip(last,"l","0")")""" "line_after" last "= noteline """time() "-end- CUT --" copied, "lines" "copied to "CUTDSNnn", lines("||, strip(first,"l","0")"-"strip(last,"l","0")")""" "line_before .zfirst = msgline """time() " CUT --" copied, "lines" "copied to "CUTDSNnn", lines("||, strip(first,"l","0")"-"strip(last,"l","0")")""" end if editopt = 1 then do if v1 = "REXX370" then address "TSO" "$EDIT" CUTDSN if v1 = "REXXSAA" then address "cmd" "spf2" cutdsn "/X" end return 0 mainframe: procedure expose q. qcnt CUTDSN autoedit editopt other, CUTDSNnn; userid = SYSVAR('SYSUID') userid = strip(sysvar('sysuid')) prefix = strip(sysvar(syspref)); if prefix='' then prefix=userid CUTDSN = "'"prefix".CUTDSN"||other||".list'" /* i.e. userid.CUTDSN.LIST */ test = SYSDSN(CUTDSN) status = msg('off') if test = "OK" then address "TSO" "DEL" CUTDSN status = msg('on') Address "TSO" , 'ALLOC FI(CUTDSN) NEW CAT SPACE(45 45) TRACKS UNIT(SYSDA)' , 'LRECL(255) RECFM(V B M) BLKSIZE(3156)' , "DSN("CUTDSN") REUSE" status = msg('off') Address "TSO" "EXECIO * DISKW CUTDSN (STEM Q. FINIS" address "TSO" "FREE FILE(CUTDSN)" return PComputer: procedure expose q. qcnt CUTDSN nxopt CUTDSNnn; /* macros named cutR, appendR, pasteR */ CUTDSN = "c:\junk\"CUTDSNnn".dat" stream(cutdsn,'C',"CLOSE") /* close the file*/ address "CMD" "DEL" cutdsn do i=1 to qcnt; call lineout CUTDSN, q.i;end; call lineout CUTDSN /* close file*/ stream(cutdsn,'C',"CLOSE") /* close the file*/ return