/* REXX -- @COMPARE maro to compare file in edit with another file --. Author: David McRitchie, created 1988/02/24 is03 "The REXX Macros Toolbox", DMcRitchie@hotmail.com Macro: is03.spf2.macro(@COMPARE) -- CopyFile on MVS for OS/2 C:\spfmacro\@COMPARE.SPF macro -- Private copy on OS/2 is03.libr.clist(@COMPARE) -- Development on TSO -- no changes required from TSO to SPF/PC using OS/2 2.1 .......................... Updated 1992/01/16 16:44 is03 REXX converted 1992/05/29 D.McRitchie from clist Updated 1993/01/21 13:56 is03 -- utilize cursor REXX rewritten 1994/04/29 D.McRitchie for TSO and SPF/PC Rewritten to do either even though more coding used. (Old Rexx version is @COMPold). REXX/2 users should use COMPARE instead 1997/04/24 will insert quick usage primarily for * but not R Title: @COMPARE text in edit with dsn(member) Users: TSO ISPF edit users | Script/VS users ===> @COMPARE * -- Compare workspace to current member/file cannot be use with another dataset. ===> @COMPARE ** -- Compare curr. member/file to file at CURSOR ===> @COMPARE -- Compare curr. member/file to file at CURSOR ___SPF/PC implementation of @COMPARE ===> @COMPARE * -- Compare active session to saved file ===> @COMPARE filename.ext -- Compare current saved file to filename ===> @COMPARE filename. -- Compare single node filename w/o .EXT ===> @COMPARE file.name.ext -- Compare to fully qualified filename ===> @COMPARE * R -- Reverse NEW/OLD datasets ___TSO implementation of @COMPARE ===> @COMPARE sys1.tsoclist -- TSO compare to member in dataset ===> @COMPARE data.set(member) -- TSO comparison to oldfile ===> @COMPARE 'data.set.name' -- Compare curr. to a sequential file ===> @COMPARE member -- Compare curr. to another member ===> @COMPARE (member) -- Compare curr. to explicit member ===> @COMPARE CLIST -- Compare curr. sys1.tsoclist ===> @COMPARE member R -- Reverse NEW/OLD datasets @COMPARE simplifies use of SuperC w/o PDF 3.11 SuperC panel SuperC can be invoked ===> TSO q superc use listing type: delta process options: seq | noseq options: ( ---- for SuperC ) LISTING(OVSUM|DELTA|CHNG|LONG|NOLIST) CTYPE(FILE|LINE|WORD|BYTE) process(cmpcol 2:72) limit compare to cols 2:72 seq noseq cobol anyc dpplcmt dpcbcmt SEQ/NOSEQ will be created provided SYSIN() not presented and seq or noseq is not already in PROCESS() options. EDIT override normal browse mode of results PRINT at ahcenter using vpsprint, forces edit option other options: R reverse olddsn with newdsn for compare. *----------------------------------------------------------*/ address "ISREDIT"; "macro (file2)" "(dataset) = dataset"; dsname=dataset /*dsname is current TSO*/ "(member) = member" Parse version V1 V2 V3 V4 V5 if v1 = "REXX/2" then do if file2 = "*" then file2 = member "COMPARE" file2 zedlmsg = "Use COMPARE it works better" call msg0 exit 0 end "(DCHANGED) = DATA_CHANGED" call note time('N') "@COMPARE" file2 if file2 = "?" /*help*/ | FILE2 = "FILE2" /*misuse, is not TSO*/ then do; address "TSO" "clist @compare help";exit 1;end; /* initializations for TSO comparison using SuperC ----------*/ R=""; call initTSO /* mainly though R is valid for SPF/PC */ file2=strip(file2) if v1 = "REXX370" then if member \= "" then dataset=dataset"("strip(member)")" newfile=translate(strip(dataset)) if file2 = '' | file2 = '**' | file2 = 'CURSOR' then do /* obtain file2 at .zcsr*/ /* for a PDS must be complete name, * not valid spf/pc or TSO*/ file2 = '' "(LINE) = line .zcsr" "(row,col) = cursor" if row=0 | col = 0 then do; zedsmsg="CURSOR";zedlmsg="Place CURSOR on filename" if v1="REXX370" then ZEDLMSG = "dataset '"oldx"' --" SYSDSN("'"oldx"'"), dsninfo0 dsninfo1 call msg0 exit 12 end; "label .zcsr = .dsn 0" line=translate(line) i=verify(substr(line,col),, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.\:_-@#$()'''); line = substr(line,1,col+i-2) B = col+i-2 do i= col+i-2 to 1 by -1 j = pos(substr(line,i,1),, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.\:_-@#$()'") if j=0 then leave; end; /* try to determine if it is the same file as one we are in*/ /* comparison not too good since dataset is fully qualified */ file2 = substr(line,i+1) if file2='' then do;call note ' sorry, No Name at .ZCSR';exit 12;end file2 = translate(file2) end /*there will be more complete test for PC equivalents */ if v1 = "REXX370" then do; /* file2 in --> oldfile out */ if substr(file2,1,1) = "'" then parse var file2 "'"oldfile"'" /*'*/ else do if file2 \= '*' then if substr(file2,length(file2),1) = ')' then oldfile=file2 else do idot = pos('.',file2) if idot = 0 then oldfile = dsname"("file2")" else oldfile = file2"("member")" end end end /* file2 in --> oldfile out, below*/ if v1 = "REXXSAA" | V1 = "REXX/2" , then do; /* DOS, if no period use same .EXT*/ if file2 \= '*' then do; f2dot = pos('.',file2) if length(file2)<9 then if f2dot = 0 then do l=length(dataset); if substr(dataset,l-3,1)='.' then file2=file2||substr(dataset,l-3) end if v1 \= "REXX/2" then do; /* use PATH to see if datasets compared really have same name*/ Call RxFuncAdd "SysSearchPath", "REXXUTIL", "SysSearchPath"; fspec = SysSearchPath('PATH', file2) oldfile = fspec if oldfile = "" then do call note " FSPEC from SysSearchPath was empty -- use file2" env="OS2ENVIRONMENT" if v1 = "REXX/2" then env = "CMD" call note " Current Path =" value('path',,env) call note " file2="file2 oldfile = file2 end end else do oldfile = file2 end end end newfile=translate(newfile) oldfile=translate(oldfile) if newfile = oldfile then do if dchanged = "YES" then do call note " "file2" is the old file entered on parm," call note " comparison will be to the active session" call note " as if entered as ===> @COMPARE *" file2 = '*'; /* so will use already programmed usage*/ end else do ZEDSMSG = "SAVED equal";ZEDLMSG = "Member" member "has been", "saved (or is unchanged), can only compare as equal to itself,", "in other words you goofed";call msg0 call note " If you wish to compare the unsaved workspace to" call note " the saved file use ===> @COMPARE *" exit 1 end end if file2 \= '*' then do; If dchanged = "YES" then call NOTsaved /** may EXIT if not saved */ call COMPARE newfile oldfile return rc end /* Asterisk -- we will compare changes in workspace to saved file */ IF DCHANGED = "NO" THEN DO ZEDSMSG = "Saved Equal" ZEDLMSG = "No point to checking UNCHANGED dataset to itself" /*--- address is required below, but not permitted in SPF/PC */ call msg0 /* ISPEXEC MSG(ISRZ000) */ exit 0 END /* create temporary dataset from workspace */ if v1 = "REXX370" then call TSOwork else if v1 = "REXXSAA" | v1 = "REXX/2" then call PCwork else do; call note " error not REXX370, REXX/2 nor REXXSAA";exit 12;end; /* compare workspace dataset as NEW to saved dataset as OLD */ call compare newfile oldfile return 0 NOTE: parse arg arg; "line_before .zf = noteline (arg)"; return NOTsaved: SAY '*************************************************************' SAY '* YOUR FILE HAS NOT BEEN SAVED AFTER MAKING CHANGES *' SAY '* *' SAY '* CANNOT COMPARE UNLESS YOU SAVE -- Hit enter to terminate *' SAY '************************* -- OR -- **************************' SAY ' REPLY or type in "CAN" to terminate request' SAY ' REPLY "SAVE" | "SAV" to save then resume @COMPARE' SAY ' REPLY "CANCEL" | "CAN" if you do not want to COMPARE', 'at this time'; SAY ' ' SAY ' You could have compared to workfile with ===> @COMPARE *' pull PARM1;parm1 = translate(parm1) if SUBSTR(PARM1,1,3) \= "SAV" then do ; call note " "time('n')" @COMPARE terminated due to UNSAVED data" zedlmsg = "Data Has not been SAVED -- NOT @COMPAREed" call msg0;Exit 1 end "SAVE" if rc > 1 then do call note " SAVE failed, save file before invoking @COMPARE" exit 1 end call note " You chose to SAVE after @COMPARE was invoked" return MSG0: /* SPF/PC invokes SETMSG in incorrectly */ if v1 = "REXXSAA" | v1 = "REXX/2" then /*Address*/ "ISPEXEC" "SETMSG MSG(ISRZ000)" else Address "ISPEXEC" "SETMSG MSG(ISRZ000)" "UP max" return 0 TSOwork: /* create temporary file from TSO ISPF workspace */ call note " @COMPARE -- You are in TSOwork" cutddsn = userid".cutddsn.list" /*userid preferred to prefix*/ test = SYSDSN("'"cutddsn"'") status = msg('on') if test = "OK" then do Address "TSO" , 'ALLOC FI(CUTDDSN) old SPACE(45 45) TRACKS UNIT(SYSDA)' , 'LRECL(255) RECFM(V B M) BLKSIZE(3156)' , "DSN('"cutddsn"') REUSE" end else do Address "TSO" , 'ALLOC FI(CUTDDSN) NEW CAT SPACE(45 45) TRACKS UNIT(SYSDA)' , 'LRECL(255) RECFM(V B M) BLKSIZE(3156)' , "DSN('"cutddsn"') REUSE" end "(last) = linenum .zlast"; q.0 = last do i = 1 to q.0 "(line) = line" i q.i=line end status = msg('off') Address "TSO" "EXECIO * DISKW CUTDDSN (STEM Q. FINIS" address "TSO" "FREE FILE(CUTDDSN)" /*if autoedit = 1 then address "TSO" "$EDIT" cutddsn */ oldfile=newfile newfile=cutddsn return PCwork: /* create temporary file from SPF/PC workspace */ if v1 \= "REXXSAA" & v1 \= "REXX/2" then exit 16 /* md c:\temp -- if you do not have one already*/ filex = "c:\temp\contrast.xxx" /* approx. of a temporary file*/ address "CMD" "del" filex "(last) = linenum .zlast" do i = 1 to last "(line) = line" i call lineout filex,line end call lineout filex /*if autoedit = 1 then address "CMD" "SPF2" filex */ oldfile=newfile newfile=filex return InitTSO: "(row,col) = cursor";row=row+0;col=col+0 dsninfo0= " as identified with cursor at ("row","col"). ", "When no options are specified,", "or the ** option is used, the cursor must be", "placed at a valid member, dsn, or dsn(member). " dsninfo1 = " Dataset options may be specified --- ", "Use * to compare workspace to actual saved data. Use **", "to compare workspace to dataset or member at cursor. ", "Use DSN to specify dataset later. ", "For other @COMPARE options see help information", " COMMAND ====> TSO clist @COMPARE help ", " " r=""; BROWSE="BROWSE"; DSN=""; PRINT=""; macrox="" file2=translate(" "file2" ") i=pos(' R ',file2); if i\=0 then do; R="R"; file2=substr(file2,1,I)||substr(file2,i+3);end i=pos(' INX ',file2); if i\=0 then do; INX='*'; macrox="MACRO(@COMPINX)"; BROWSE="EDIT"; file2=substr(file2,1,I)||substr(file2,i+5);end i=pos(' PRINT ',file2); if i\=0 then do; PRINT="PRINT"; file2=substr(file2,1,I)||substr(file2,i+7);end if v1 = "REXXSAA" | v1 = "REXX/2" then return /* rest only for SuperC under TSO */ userid = strip(SYSVAR('SYSUID')) prefix = strip(sysvar(syspref)); if prefix='' then prefix=userid Parse var file2 file2 " LIST(" list ") " remain file2=file2 remain parse var file2 file2 " CTYPE(" ctype ") " remain file2=file2 remain parse var file2 file2 " PROCESS(" process ")" remain file2=file2 remain parse var file2 file2 " SYSIN(" sysin ")" remain file2=file2 remain "(NUMBER) = NUMBER" if process = "" then if sysin = "" then do; IF substr(number,1,2) = "ON" then process = "SEQ" process; else PROCESS="NOSEQ" process; end; file2=file2 remain i=pos(' EDIT ',file2); if i\=0 then do; browse="EDIT"; file2=substr(file2,1,I)||substr(file2,i+6);end; file2=strip(file2) if file2 = "CLIST" then file2 = "SYS1.TSOCLIST" else if file2 = "DSN" then do /* prompt for dsname*/ say "For DSN what value would you like to use?" pull file2; end else if file2 = "*PASTE*" then file2 = userid".CUTDSN.LIST" else if file2 = "CMD" then file2 = "IS03.PC.CMD" else if file2 = "CLIST" then file2 = "SYS1.TSOCLIST" else if file2 = "EMERG" then file2 = "EMERG.LIBR.CNTL" else if file2 = "PROC" then file2="SYS1.USERPROC" else if file2 = "PROD01" then file2="TSOPROD.PROD01.CNTL" else if file2 = "SPF2" then file2="is03.spf2.macros" i=words(file2) if i > 1 then do; file2 = strip(file2) i = pos(' ',file2) remain = substr(file2,I+1) file2 = substr(file2,1,I-1) call note "Remaining will be entered--" remain end /* next line provides for a member named CLIST or PROC */ if substr(file2,1,1) = "(" then parse var file2 "("file2")" return COMPARE: /* compare newfile to oldfile */ arg newfile oldfile if r="R" then do; x=oldfile; oldfile=newfile; newfile=x; end; call note " NewFile="newfile", OldFile="oldfile if v1 = "REXXSAA" | v1 = "REXX/2" then do call note " GFC -- Graphical File Compare" call note " GFC" newfile oldfile if newfile="OLDFILE" | newfile ="NEWFILE", | oldfile="OLDFILE" | oldfile ="NEWFILE" then do call note "BIG trouble in River City -- You''re all "||, "washed up in this town, Mister" env="OS2ENVIRONMENT" if v1 = "REXX/2" then env = "CMD" call note " Current Path =" value('path',,env) call note " file2="file2 exit 1 end /* address "CMD" "GFC" newfile oldfile */ if v1 = "REXXSAA" then address "CMD" "c:\contrast\coNTRAST" newfile oldfile if v1 = "REXX/2" then address "CMD" "FCompare" newfile oldfile return end; /* TSO comparison using SuperC ------------------------*/ if ctype="" then ctype="LINE" if process\="" then process="process("process")" if sysin \= "" then sysin="SYSIN("sysin")" listing=list; if listing="" then listing="DELTA" x = sysdsn("'"oldfile"'") if x = "OK" then do Address "TSO" "%SUPERC NEWFILE('"newfile"')", "OLDFILE('"oldfile"')" BROWSE "ctype("ctype")", "listing("listing")" process sysin macrox remain rcx = rc call note " "process sysin macrox remain if rcx = 1 then if INX = "*" then do address "ISPEXEC" "EDIT dataset('"prefix".SUPERC.LIST')", "MACRO(@COMPINX)" Address "TSO" "COPY SUPERC.LIST libr.clist(ZCOMPX99) NONUM" ZEDSMSG = "ready for %ZCOMPX99" ZEDLMSG = 'ZCOMPX99 is in your LIBR.CLIST and ready to use' call note " "zedlmsg call msg0 return 1 end end else do;call note " Sorry --" oldfile "--" x; zedsmsg="DSN?" zedlmsg="Sorry --" oldfile "--" x; call msg0 "up max";exit 0 end; return rc /* The coding of @COMPARE has been tested on SPF/PC and on TSO. Our version of the %SUPERC clist includes a BROWSE/EDIT option and therefore differs slightly from the orginal example %SUPERC clist formerly installed into SYS1.SAMPLIB(ISRSCLST) which is now installed into SYS1.ISPFPDF.ISRSAMP(ISRSCLST). */ /*********************************************************************/ /* In SPF/PC 3.0 SuperC is not available so GFC was used */ /* If SPF/PC 4.0 provides SuperC, then this macro possibly can be */ /* changed to use SuperC in place of the Graphical File Compare(GFC)*/ /* Comparison is done using the GRAPHICAL FILE COMPARE (GFC) program */ /* from IBM. It supercedes a previous ESDTOOLS program named */ /* CONTRAST that had been made available on IBM bulletin boards. */ /* -Yellow -- FileA -- current (NEW) file, (workspace, if * used) */ /* -Red -- FileB -- specified (OLD) file, (saved file, if * used) */ /* Invocation of GFC is as follows: GFC */ /*********************************************************************/