/* PASTE: Portion of CUT/PASTE, with various options (REXX) */ /* Author: David McRitchie, "The REXX Macros Toolbox", 1991/04/24 */ /* derived from NaSPA 004 member PASTE, added KEEP,(member) */ /* 1994/05/26 Converted to REXX, added COL(),VALUE() options */ /* 1994/06/24 Ability to used numbered CUTDSN## datasets */ /*-------------------------------------------------------------------*/ /* Macro: PASTE (PASTER for SPF/PC usage) */ /* Purpose: Paste lines that have previously been cut, or */ /* paste from member in a permanent PASTE pds library.*/ /* Companion Macros: CUT, APPEND -- spf/pc CUTR, APPENDR */ /* Related Macros: REFORMAT, @IDATA */ /*********************************************************************/ /* 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. */ /*********************************************************************/ /* */ /*******************************************************************/ /* Wait to PROCESS any line commands until MACRO init. completed. */ /*******************************************************************/ Address "ISREDIT";"macro NOPROCESS (tokens)"; Itokens=tokens tokens = " "translate(tokens)" "; Member="" other="";CUTDSNnn="CUTDSN" recno=0 /* obtain parameters: COL(col), VALUE(value), KEEP */ i=pos(' HELP ',tokens); if i=0 then i=pos('?',TOKENs); if i \= 0 then do; address "TSO" "CLIST CUT HELP"; exit 1;end; i = pos(' KEEP ',tokens); if i =0 then keep=""; else do keep="KEEP"; tokens=substr(tokens,1,i)substr(tokens,I+6);end i = pos(' EDIT ',tokens); if i =0 then edit=""; else do edit="EDIT"; tokens=substr(tokens,1,i)substr(tokens,I+6);end parse var tokens left ' COL(' col ') ' right; tokens = left right parse var tokens left ' VALUE(' value ')' right; tokens=left right parse var tokens left "(" member ")" right; if member \= "" then keep = "KEEP" remaining = left right if remaining \= "" then do remaining = strip(remaining) if datatype(remaining,'N') = 1 then do other = remaining + 0; remaining="" CUTDSNnn = CUTDSNnn||other end end if remaining \= "" then do zedsmsg = "?" remaining zedlmsg = "remaining tokens unknown: "remaining Address "ISPEXEC" "setmsg msg(isrz000)" exit 1 end pasting = 1; include = 0; q.=""; truncat=""; rcnote="" parse version v1 v2 v3 if v1 = "REXX370" then Nop; else if v1 = "REXXSAA" then Nop; else do; say "v1="v1;exit 12;end; /******************************************************************/ /* Allocate temporary dataset created by PDFCUT edit macro. */ /******************************************************************/ if v1 = "REXX370" then do userid = strip(sysvar('sysuid')) prefix = strip(sysvar(syspref)); If prefix='' then prefix=userid dataset = prefix"."CUTDSNnn".LIST" end if v1="REXXSAA" then dataset = "c:\junk\"CUTDSNnn".dat" if member \= "" then do dataset = prefix".LIBR.PASTE"||other||"("strip(member)")"; keep="KEEP" if v1="REXXSAA" then dataset = "c:\is03\"member".CMD" end; if v1 = "REXX370" then do x = sysdsn("'"dataset"'") if x \= "OK" then do "PROCESS DEST" /* If rcx \= 8 then do; say "SORRY";Exit 12; End */ "(Cdest) = linenum .zdest"; CdestP1=Cdest+1 /*********************************************************************/ /* Perform RESET operation to get rid of the destination char. "A" */ /*********************************************************************/ ZEDSMSG = "work dataset not found" ZEDLMSG = "PASTE (work) dataset '"dataset"',", "could not be found" Address "ISPEXEC" "setmsg msg(isrz001)" /* alarm */ if Cdest > 0 then do "line_after .zdest = noteline """||, "Have reset .ZDEST command A(fter) or B(efore)", "immediate above or below""" "reset" Cdest CdestP1 "command" end Exit 12 End End If EDIT = "EDIT" then do ZEDSMSG = "PASTE EDIT" ZEDLMSG = "You are viewing your paste dataset" if member \= "" then zedlmsg = "You are viewing a member", "in your permanent PASTE partitioned library" Address "ISPEXEC" "setmsg msg(isrz001)" /* alarm*/ if v1 = "REXX370" then Address "ISPEXEC" "edit dataset('"dataset"')" if v1 = "REXXSAA" then address "cmd" "spf2" dataset ZEDSMSG = "PASTE EDIT -- COMPLETED" ZEDLMSG = "EXAMINATION OF PASTE DATASET COMPLETED" Address "ISPEXEC" "setmsg msg(isrz000)" Exit 1 End /****************/ if col||value \= "" then if value="" | col="" then do /* Only COL() VALUE() provided after */ /* EDIT, VIEW, or KEEP have been tested for */ ZEDSMSG = "" ZEDLMSG = "COL("col") VALUE("value") -- both must be", "nonblank when either is used" Address "ISPEXEC" "setmsg msg(isrz000)" Exit 9 End If col \= "" then do; keep="KEEP";pasting=0; Lvalue = length(value); End; if v1 = "REXX370" then do; Address "TSO" "ALLOC F(TEMPFLE) DA('"DATASET"') SHR REUSE" ADDRESS "TSO" "EXECIO * DISKR tempfle (STEM Q. FINIS" end if v1 = "REXXSAA" then call PC_QLOAD /* If FILE IS EMPTY WE CAN PASTE (NO LABELS DEST OR RANGE EXISTS)*/ "(DEST) = LINENUM .ZFIRST" If dest = "000000" then signal USEDEST /*********************************************************************/ /* Tell macro that we will PROCESS B (Before) or A (After) */ /* destination commands. Only DEST is valid anything else is not. */ /* Unexpected C range caused abend S-0C4, so we will check for it. */ /*********************************************************************/ if v1 = "REXXSAA" then "PROCESS DEST RANGE C M" if v1 = "REXX370" then "PROCESS DEST RANGE C M" rcx = rc if v1 = "REXX370" then do /************* will not function in SPF/PC due to bugs *****/ "(CMD) = RANGE_CMD" If rcx = 0 | rcx = 8 then do ZEDSMSG = "RANGE NOT ALLOWED rc"=rcx ZEDLMSG = "RANGE" cmd "NOT USED WITH PASTE --", "use dest ""A"" or ""B"" only" say zedlmsg; say zedlmsg; Address "ISPEXEC" "setmsg msg(isrz001)" /* alarm */ Exit 12 /* HIGH RETURN CODE LEAVES COMMAND */ End If rcx \= 4 then do ZEDSMSG = "PASTE PENDING" ZEDLMSG = "An ""A"" or ""B"" line command has NOT been", "specified, or line commands conflict" say zedlmsg; say zedlmsg; Address "ISPEXEC" "setmsg msg(isrz001)" /* alarm */ Exit 12 /* high return code leaves command */ End /************* will not function in SPF/PC due to bugs *****/ end /*********************************************************************/ /* The DEST line number for "A" or "B" entered by user. */ /*********************************************************************/ "(DEST) = LINENUM .ZDEST" /*********************************************************************/ /* After the ISREDIT LINENUM command, it is necessary to strip the */ /* dest variable of any leading zeroes. */ /*********************************************************************/ USEDEST: DEST = dest + 0 sdest = dest /*********************************************************************/ /* Find out if sequence numbering is on. */ /*********************************************************************/ "(NUMON) = NUMBER" /*********************************************/ /* TSO/E ERROR ROUTINE BEFORE USE OF */ /* CLIST QSAM ROUTINES TO READ WORK DATASET. */ /*********************************************/ "(caps) = caps" Do recno = 1 to q.0; x = q.recno if caps = "ON" then do if x \= translate(x) then do caps = "OFF" "CAPS" caps "LINE_AFTER" dest "= noteline ""Caps turned OFF""" end end if col \= "" then do j=1 to 1 if include = 1 then if x = "" then do; include=0; leave j; end; if translate(substr(x,col,lvalue)) \= value then iterate recno include = 1 end "LINE_AFTER" dest "= dataline (x)" If RC = 4 then Truncat = " -Data Truncated-" if dest = sdest then "LINE_AFTER" dest "= NOTELINE """time(), "START OF PASTE" Itokens"""" dest = dest + 1 end recno; x = TIME() "-E"||"nd- of PASTE" Itokens "line_after" dest "= Noteline (x)" if numon = "ON" then if truncat \= "" then "line_before", dest "= noteline """time() "Number mode in effect", "truncation loss may or may not be real""" /* Delete userid.CUTDSN.LIST unless KEEP -- double checking*/ c = "moved"; if keep = "KEEP" then c="copied" if member = " " then d="dataset"; else d="member" If keep \= "KEEP" then do; /*insure we d-o not scatch a PDS */ if v1 = "REXX370" then do x = listdsi("'"dataset"'") If SYSDSORG = "PS" then do x = msg('off') address "TSO" "DELETE '"dataset"'" x = msg('on') end else c = "copied" end; else do; c="copied"; d="file"; end; end ZEDSMSG = "PASTE SUCCESSFULL" ZEDLMSG = "PASTE work dataset was" c "into current" d Address "ISPEXEC" "setmsg msg(isrz000)" Exit 1 PC_QLOAD: /* for REXXSAA put entire file into stem (Q.) . */ if v1 \= "REXXSAA" then do; say "PC_QLOAD not REXXSAA";exit 12;end CUTDSN = "c:\junk\"CUTDSNnn".dat"; myfile = CUTDSN Call Stream myfile, "Command", "Open read"; If Result \= "READY:" then do; Say "Output '"myfile"' open returned '"Result"'"; Signal InnerError; End; qcnt = 0 Do forever; X = LineIn(myfile); RC = Stream(myfile, "Description"); Select; /*match up like a DO */ When RC = "READY:" then NOp; When RC = "NOTREADY:EOF" then Leave; Otherwise Call InputError RC; Signal InnerError; exit End; qcnt = qcnt+1; q.0 = qcnt; q.qcnt = x End Call Stream myfile, "Command", "Close"; If Result \= "READY:" then do; Say "Output '"myfile"' close returned '"Result"'"; Signal InnerError; End; /********** temporary -- until tested on a PC *********/ /* do i=1 to q.0; say q.i; end; ------------*/ /******************************************************/ Return InnerError: If Stream(myfile, "Description") \= "UNKNOWN:" then do; Call Stream(myfile, "Command", "Close"); If Result \= "READY:" then do; Say "Output '"myfile"' emergency close returned '"Result"'"; ReturnCode = Max(16, ReturnCode); End; End; Exit Max(12, ReturnCode); /*******************************************************/ /* COL() VALUE() INCLUDE pasting ADDED D.MCR 1992/09/22 */ /*******************************************************/ /*********************************************************************/ /* 111 VALUE OF 111 IS AAAA */ /* 222 VALUE OF 222 IS BBBB */ /* CONTINUED LINE OF 222 */ /* 333 VALUE OF 333 IS CCC */ /* &.222 ANOTHER 222 HERE */ /* ANOTHER CONTINUED LINE OF 22 */ /*********************************************************************/