parm !fset,!fcode="",!qoptionx="L",!qfrom="",!qto="" & !qcase="Y",!qcolrng="",!qlinrng="ALL" setvar _qstarthptimef hptimef setvar _qstarthpcpumsecs hpcpumsecs echo QUADAUTO v.2.0 08/31/2007 [A tool to assist QUAD editing.] echo For help and examples see scripts's comments at start and end. echo Beechglen Development, Inc. echo For quality HP3000 and HP9000 software and hardware support. echo www.beechglen.com (513) 922-0509 Eastern Standard Time pause 2 setvar _qprogram 'quad.pub.sys' if finfo('!_qprogram',0) if finfo('!_qprogram',-9) <> 1029 & and finfo('!_qprogram',-9) <> 1030 echo quadauto: The file specified as the QUAD program echo via the variable '_qprogram' does exist, but this echo file is not a program file (filecode PROG or NMPRG). echo Variable _qprogram value=!_qprogram echo Here are !_qprogram's file characteristics (:listfile ,2): listfile !_qprogram,2 echo Please locate a valid copy of the QUAD program. Then echo point the QUADAUTO script to this copy by issuing a echo command like the following BEFORE QUADAUTO execution: echo setvar _qprogram 'quad.hpgroup.hpacct' echo Processing terminated. return endif else echo quadauto: The file specified as the QUAD program echo via the variable '_qprogram' does NOT exist. echo Variable _qprogram value=!_qprogram echo Please locate a valid copy of the QUAD program and echo point the QUADAUTO script to it by issuing a command echo like the following BEFORE QUADAUTO execution: echo setvar _qprogram 'quad.hpgroup.hpacct' echo Processing terminated. return endif if hpinteractive echo echo quadauto has been found to work successfully in all MPE/iX echo OS environments from MPE/iX 5.5 powerpatch 4 through 7.5+. echo echo QUAD VERSION: dated June 1991, code = "PROG", eof = 5723 echo echo QUADAUTO processing is subject to the limits of QUAD! comment For example, QUAD's help on the 'text command specifies: comment Files (to be text edited) may be a standard flat file and comment if a flat file, Quad automatically recognizes numbered comment and COBOL files and handles them appropriately. comment A KSAM key or data file may be texted and edited, but it comment is treated by Quad as an ordinary file and Quad will comment allow a keep back to the original file ONLY if no lines comment have been added or deleted. Attepts to text RIO, message comment or circular files fail with an error message. echo echo If you don't have a copy of QUAD, you will need to echo get a copy. Please contact Beechglen Development, Inc. echo at (513) 922-0509 E.S.T. or via support@beechglen.com echo echo QUADAUTO determines the location of the QUAD program echo via a variable named _qprogram. If this variable is echo not found, then QUADAUTO will create the variable and echo assign the default value of 'quad.pub.sys' to it. echo echo QUADAUTO utilizes the TILDE ('~') character extensively. echo Uses various variables incl many beginning with "_q". echo Temporary files used: QLISTZZ,QFILEZZ,QCOMMZZ,QTRAILZZ echo Option "X" utilizes a permanent file name QUADAUIN. echo echo Lockworded files and files w/EOF=0 are bypassed. echo Any file named QUADAUTO or QUADAUIN is bypassed. endif comment For your information, QUADAUTO uses the TILDE character comment (a '~') to delimit strings. So, if you are going to be comment using a string that contains a '~', you will need comment to modifiy QUADAUTO to use a special character delimiter comment other than '~'. Do not use [/,@,!,*,+,-,. and ',']. comment ************************************************************* comment 12/02/1998 v1.0 Initial release. comment 07/03/2003 v1.1 Removed filename from keep statements to comment prevent QUAD from keeping files numbered. comment 08/29/2007 v2.0 mods that included changing the specified comment location of the QUAD program from the use of a file equate comment to the use of a user variable. Several cosmetic changes. comment Changed parm line from !fset="" to !fset to disallow null comment being allowed as later :listfile interprets this as '@'. comment ************************************************************* comment for safety, delete any PARM var settings that may exist: setvar hpmsgfence,1 comment setvar hpmsgfence,0 comment This begins the verification of input vars for processing. comment ************************************************************ setvar _qspacechar pos (" ","!fset",1) if not (_qspacechar = 0) echo quadauto: A fileset value must be entered and what echo you enter cannot contain any spaces. echo Processing terminated. return endif if (ups("!qoptionx") <> "C" and ups("!qoptionx") <> "L" & and ups("!qoptionx") <> "X") echo echo quadauto: Option must be C or L or X. echo (Your input cannot contain spaces.) echo Processing terminated. return endif comment comment set the following variable to "N" prior to setting it below setvar _qabscolrngchg "N" comment if ups("!qoptionx") <> "X" if ups("!qoptionx") = "C" if "!qfrom" = "" echo echo quadauto: For option C, Changing a string, Parm 4 echo is not allowed to be a null value. echo Processing terminated. return else setvar _qleft_paren pos ("(","!qfrom",1) setvar _qslashchar pos ("/","!qfrom",1) setvar _qright_paren pos (")","!qfrom",1) if _qslashchar > 0 and _qleft_paren > 0 and _qright_paren > 0 setvar _qabscolrngchg "Y" setvar _qleftcolumnwidth !_qslashchar - (!_qleft_paren + 1) setvar _qrightcolumnwidth !_qright_paren - (!_qslashchar + 1) setvar _qstartchgcol & str("!qfrom",(!_qleft_paren + 1),(!_qleftcolumnwidth)) setvar _qendchgcol & str("!qfrom",(!_qslashchar + 1),(!_qrightcolumnwidth)) setvar _qfromcolrng "!_qstartchgcol" + "/" & + "!_qendchgcol" endif comment cleanup, since some are used later... continue deletevar _qleft_paren continue deletevar _qslashchar continue deletevar _qright_paren continue deletevar _qstartchgcol continue deletevar _qleftcolumnwidth continue deletevar _qrightcolumnwidth continue deletevar _qendchgcol endif endif endif if ups("!qoptionx") <> "X" continue if ups("!qoptionx") = "C" if "!qto" = "" echo quadauto: For option C, Changing a string, Parm 5 echo is allowed to be a null value, but this echo can be unusual. echo endif endif endif if ups("!qoptionx") <> "X" if (ups("!qcase") <> "Y" and ups("!qcase") <> "N") echo echo quadauto: Case must be a value of Y or N echo Processing terminated. echo return endif endif if (ups("!qoptionx") = "C" and "!_qabscolrngchg" = "Y" & and "!qcolrng" <> "") echo echo quadauto: You have requested an absolute column range echo change by putting a value of form '(##/##)' echo for the 'from' variable (parm # 4). Such a echo request prohibits assigning any value to the echo column range variable (parm # 7). echo You have specified a value for parm # 7. echo Processing terminated. return endif comment comment force a null entry to qlinrng prompt to have value of "ALL" comment if "!qlinrng" = "" setvar qlinrng "ALL" endif comment now, if OPTION 'L', make sure the user did not try to comment specify a line specification like '@i:xyz:', since this comment unacceptable by QUAD. comment if ups("!qoptionx") = "L" setvar _qleft_paren pos ("(","!qlinrng",1) setvar _qright_paren pos (")","!qlinrng",-1) if not (_qleft_paren = 0 and _qright_paren = 0) echo echo quadauto: The 'L' (list) option does not allow a echo 'process lines including string' designation. echo That is, parm 8 cannot be '@I:XYZ:' or such. echo echo quadauto: Invalid specification. See QUADAUTO examples. echo Processing terminated. return endif endif comment comment This ends the verification of input variables for processing. comment ************************************************************ if ups("!qoptionx") = "X" setvar _quadauin_exists finfo("QUADAUIN",0) if _quadauin_exists = TRUE setvar _qaudauineof finfo("QUADAUIN",19) if _qaudauineof = 0 echo echo quadauto: Xecute file processing was specified but echo the permanent Xecute file named QUADAUIN is empty. echo echo Processing terminated. return endif else echo echo quadauto: Xecute file processing was specified but echo the permanent Xecute file named QUADAUIN, does not exist. echo echo Processing terminated. return endif endif setvar hpmsgfence,1 comment comment the code following, if hpinteractive was not indented! comment if hpinteractive comment comment echo echo **************************************************************** echo WARNING! "THE BEST LAID PLANS OF MICE AND MEN OFTEN GO ASTRAY" echo IN OTHER WORDS, YOU DO HAVE A BACKUP OF THESE FILES echo THAT YOU ARE PROCESSING, DON'T YOU? ALSO, A 'SINGLE' echo FILE' TEST IS RECOMMENDED PRIOR TO ANY 'ENMASSE' ONES. echo **************************************************************** echo echo Please verify that you agree with the following specifications: echo echo Parm1, Fileset to process = !fset echo Parm2, Only process files with filecode = !fcode echo Parm3, X(ecute file), C(hange), L(ist) = !qoptionx if ups("!qoptionx") = "C" echo Parm4, From string OR absolute column range = !qfrom echo Parm5, To string = !qto if ups("!qoptionx") <> "X" echo Parm6, Match case of Parm4/5 strings? = !qcase endif echo Parm7, change column range (" " = all columns) = !qcolrng echo Parm8, change line range = !qlinrng elseif ups("!qoptionx") = "L" echo Parm4, Search string1 = !qfrom if "!qto" <> "" echo Parm5, Search string2 = !qto else echo Parm5, Search string2 = !qto, none given so not used. endif if ups("!qoptionx") <> "X" echo Parm6, Match case of Parm4/5 strings? = !qcase endif echo Parm7, list column range (" " = all columns) = !qcolrng echo Parm8, list line range = !qlinrng elseif ups("!qoptionx") = "X" echo echo Xecute file processing was specified. Remember, the very last echo 2 lines in QUADAUIN must be "keep;exit" and then "Y". echo echo QUAD will stop processing a Xecute file after the first error. echo echo Here is the contents of the 'Xecute' file "QUADAUIN": continue print quadauin;page=0 echo endif echo setvar _quserreply,"X" input _quserreply;prompt= & "Are the specs above correct? (Y/N) [default=N]->";wait=30 if _quserreply <> "Y" and _quserreply <> "y" THEN echo You disagree with the specifications. Processing terminated. deletevar _quserreply setvar hpmsgfence,0 return else echo Okay, you agree with the specs, QUADAUTO is now proceeding... echo endif comment comment the previous code to the following endif was not indented! comment this endif belongs to the "if hpinteractive" statement. comment endif comment comment continue purge QTRAILZZ,temp continue purge QLISTZZ listfile !fset,6 > QLISTZZ setvar _qlistzzeof finfo("QLISTZZ",19) if !_qlistzzeof = 0 echo quadauto: Attention! QUADAUTO could not find any echo files matching to the fileset that you had echo designated! Please verify your logon echo run environment: group,account,udcs,command echo files, etc and then check upon the validity echo of the fileset via the command :listfile !FSET endif setvar _qlistzzrectoproc 1 setvar _qnbrfilesprocessed,0 setvar _qnbrfilesbypassed,0 continue purge QFILEZZ while !_qlistzzrectoproc < !_qlistzzeof & or !_qlistzzrectoproc = !_qlistzzeof print qlistzz; & START=!_qlistzzrectoproc;END=!_qlistzzrectoproc > QFILEZZ INPUT _qfilezz_line < QFILEZZ setvar _qfilezz str('!_qfilezz_line',1,26) setvar _qfilezzeof finfo("!_qfilezz",19) setvar _qfcode finfo("!_qfilezz",9) setvar _qfilezz1st8chars str('!_qfilezz',1,8) setvar _qlockword finfo("!_qfilezz",33) if (!_qfilezzeof <> 0 and "!_qfcode" = "!fcode" & and "!_qlockword" = "" and "!_qfilezz1st8chars" & <> "QUADAUTO" AND "!_qfilezz1st8chars" <> "QUADAUIN") echo echo quadauto: !hptimef ...now processing file: !_qfilezz echo !_qfilezz was processed. >> QTRAILZZ echo TEXT !_qfilezz > QCOMMZZ if ups("!qoptionx") = "X" echo XECUTE !["!<" + "QUADAUIN" + "!>"] SHOW >> QCOMMZZ elseif ups("!qcase") = "Y" if ups("!qoptionx") = "C" if "!_qabscolrngchg" <> "Y" echo C & ~!qfrom~ & !qcolrng to & ~!qto~ & !qlinrng CASE SHOW >> QCOMMZZ else echo C & !_qfromcolrng to & ~!qto~ & !qlinrng CASE SHOW >> QCOMMZZ endif comment Do not use filename in following keep since this comment results in file being kept as a NUMBERED file even comment if the original file was UNNUMBERED! echo keep >> QCOMMZZ echo Y >> QCOMMZZ echo exit >> QCOMMZZ elseif ups("!qoptionx") = "L" echo L & !qlinrng & I~!qfrom~ & !qcolrng & CASE >> QCOMMZZ if "!qto" <> "" echo L & !qlinrng & I~!qto~ & !qcolrng & CASE >> QCOMMZZ endif echo exit >> QCOMMZZ endif elseif ups("!qoptionx") = "C" if "!_qabscolrngchg" <> "Y" echo C & ~!qfrom~ & !qcolrng to & ~!qto~ & !qlinrng SHOW >> QCOMMZZ else echo C & !_qfromcolrng to & ~!qto~ & !qlinrng SHOW >> QCOMMZZ endif comment Do not use filename in following keep since this comment results in file being kept as a NUMBERED file even comment if the original file was UNNUMBERED! echo keep >> QCOMMZZ echo Y >> QCOMMZZ echo exit >> QCOMMZZ elseif ups("!qoptionx") = "L" echo L & !qlinrng & I~!qfrom~ & !qcolrng & >> QCOMMZZ if "!qto" <> "" echo L & !qlinrng & I~!qto~ & !qcolrng & >> QCOMMZZ endif echo exit >> QCOMMZZ endif comment To allow the QUAD program to process the largest file comment size that it can as stated in QUAD's documentation, comment now issuing the following statement: setjcw quadfilesize 32767 !_qprogram < QCOMMZZ setvar _qnbrfilesprocessed _qnbrfilesprocessed + 1 else echo echo quadauto: bypassing the file: !_qfilezz (!_qfcode) echo !_qfilezz (!_qfcode/!_qlockword) was bypassed. >> QTRAILZZ setvar _qnbrfilesbypassed _qnbrfilesbypassed + 1 endif setvar _qlistzzrectoproc _qlistzzrectoproc + 1 endwhile echo echo By way of reminder you had specified the following to QUADAUTO: echo echo Parm1, Fileset to process = !fset echo Parm2, Only process files with filecode = !fcode echo Parm3, X(ecute file), C(hange), L(ist) = !qoptionx if ups("!qoptionx") = "C" echo Parm4, From string = !qfrom echo Parm5, To string = !qto if ups("!qoptionx") <> "X" echo Parm6, Match case of Parm4/5 strings? = !qcase endif echo Parm7, change column range (" " = all columns) = !qcolrng echo Parm8, change line range = !qlinrng elseif ups("!qoptionx") = "L" echo Parm4, Search string1 = !qfrom if "!qto" <> "" echo Parm5, Search string2 = !qto else echo Parm5, Search string2 = !qto, none given so not used. endif if ups("!qoptionx") <> "X" echo Parm6, Match case of Parm4/5 strings? = !qcase endif echo Parm7, change column range (" " = all columns) = !qcolrng echo Parm8, change line range = !qlinrng elseif ups("!qoptionx") = "X" echo echo Xecute file processing ("QUADAUIN") was specified. echo Here is the contents of the 'Xecute' file "QUADAUIN": echo continue print quadauin;page=0 endif echo echo quadauto: Activity recap follows: echo echo Number of files in the fileset = !_qlistzzeof echo Number of files processed = !_qnbrfilesprocessed echo Number of files bypassed = !_qnbrfilesbypassed echo continue print qtrailzz;page=0 echo comment now cleanup variables and workfiles comment continue deletevar _qlistzzeof continue deletevar _qlistzzrectoproc continue deletevar _qfilezz continue deletevar _qfilezzeof continue deletevar _qfcode continue deletevar _qfilezz1st8chars continue deletevar _qfilezz_line continue deletevar _quserreply continue deletevar _qlockword continue deletevar _qnbrfilesprocessed continue deletevar _qnbrfilesbypassed continue deletevar _qaudauin_exists continue deletevar _qaudauin_eof continue deletevar _qleft_paren continue deletevar _qright_paren continue deletevar _qspacechar continue deletevar _quadauin_exists continue deletevar _quadauineof continue deletevar _qabscolrngchg continue deletevar _qfromcolrng continue reset quadauin setvar hpmsgfence,0 echo quadauto: Processing completed. echo Started at !_qstarthptimef and ended at !hptimef setvar _qtotalhpcpumsecs (hpcpumsecs - _qstarthpcpumsecs) echo !_qtotalhpcpumsecs CPU milliseconds were used. deletevar _qstarthptimef deletevar _qstarthpcpumsecs deletevar _qtotalhpcpumsecs deletevar _qprogram comment comment Features: Use QUAD to list up to 2 strings comment in a fileset or replace one string with another or comment execute an Xecute file ("QUADAUIN") against a fileset. comment comment Note: The very last two lines of QUADAUTO'S Xecute file comment named QUADAUIN should be the following 2 lines: comment comment keep;exit comment Y comment comment Examples of how to use QUADAUTO: comment comment IN THE EXAMPLES BELOW A DOUBLE ',' MEANS THAT A NULL VALUE comment was entered for that parm comment comment WANT ALL FILE LINES PROCESSED?...THEN DO NOT ENTER PARM 8 comment WANT ALL COLUMNS and ALL FILE LINES PROCESSED?... comment ...THEN DO NOT ENTER PARM 7 AND DO NOT ENTER PARM 8 comment comment To LIST 1 string matching its case exactly: comment QUADAUTO fileset,,L,this,,Y comment comment To LIST 2 strings ignoring case: comment QUADAUTO fileset,,L,this,that,N comment comment To LIST "THINK" OR "Super", only if in columns 42/46, and comment only in file lines 50 though 75: comment QUADAUTO fileset,,L,THINK,think,n,(42/46),50/75 comment comment To LIST an uppercase "H" OR a lowercase "o", occuring only comment in column 134, and only in file lines 800/950: comment QUADAUTO fileset,,L,H,o,Y,(134),800/950 comment comment To CHANGE 1 string of exact case to another string: comment QUADAUTO fileset,,C,ThIs,THaT,Y comment comment To CHANGE 1 string to another ignoring case: comment QUADAUTO fileset,,C,THINK,think,n comment comment To CHANGE a range of columns in all records in a file that comment contain a certain string in a certain column, and where the comment case of the string does matter: comment QUADAUTO fileset,,C,(11/19),"XYZ - 123",Y,,"@I~S ~(4/7)" comment comment To CHANGE 1 string, and only if it occurs in columns comment 65/72, through the whole file, ignoring case: comment QUADAUTO fileset,,C,ThInK,think,n,(65/72) comment comment To CHANGE 1 string, and only if it occurs in columns comment 65/72, and only in file lines 50 though 75, ignoring case: comment QUADAUTO fileset,,C,THINK,think,n,(65/72),50/75 comment comment To CHANGE 1 string, and only if it occurs in columns comment 100 through 115, and only if its case matches exactly, and comment only if the record contains a certain specified string comment and processing every line in the file: comment ******************************************************* comment NOTE: if CASE=Y, then case of search string part does matter. comment ******************************************************* comment QUADAUTO fileset,,C,ThInK,tHiNk,y,(100/115),@I"ABC003" comment comment To CHANGE 1 string, and only if it occurs in columns comment 64 through 71, and only if its case matches exactly, and comment only if the record contains a certain specified string comment and only in lines 20 through 42: comment ******************************************************* comment NOTE: if CASE=Y, then case of search string part does matter. comment ******************************************************* comment QUADAUTO fileset,,C,ThInK,tHiNk,y,(64/71),20/42I"XYZ999" comment comment To CHANGE 1 string, and only if it occurs in columns comment 10 through 14 of lines 1->99 and only if its case matches, comment and only if the record contains a certain specified string comment that occurs in columns 64/71: comment ******************************************************* comment NOTE: if CASE=Y, then case of search string part does matter. comment ******************************************************* comment Q' fileset,,C,ThInK,tHiNk,Y,(10/14),1/99I"RQ980605"(64/71) comment comment To process files having the filecode "EDTCT": comment QUADAUTO fileset,EDTCT,F,THIS,,Y comment comment To utilize the XECUTE file command in 'QUADAUIN': comment QUADAUTO fileset,,X comment comment QUAD is a very powerful program with many, many features comment that are too numerous to give exhaustive examples for here. comment For example the NONLIT and WILD (QUAD) parms are useful. comment comment BE VERY CAREFUL WHEN USING 'WILD' and 'NONLIT'. TEST IT OUT. comment comment ! - will match any special character comment # - will match any single numeric digit (beware of '##') comment ^ - will match a single alpha char, upper or lower case comment ? - will match any character comment @ - will match zero or more chars (be very careful with this) comment comment An example of 'WILD' usage. To change all two digit numbers comment occuring in columns 10 and 11 that begin with '8' to '00', comment and only in lines 120/199, and only if the record contains comment a certain string (where case is matched) in columns 1/2: comment ******************************************************* comment NOTE: if CASE=Y, then case of search string part does matter. comment ******************************************************* comment Q' fileset,,C,8#,00,Y,(10/11),120/199I~aa~(1/2)WILD comment comment Also, QUAD's DELETE command is powerful. QUADAUTO WAS comment NOT DESIGNED for using DELETE (D) as an option. You comment may want to utilize it on your own though. For example, comment say you wanted to delete all records with "500" in columns comment 73->75. In this case, delete @I:500: (73/75) would do it. comment comment Investigate these and other features of the QUAD program by comment doing: :run quad... help... menu... and then choose an item comment like 'strings' or 'commands'... and when done... ENDHELP. comment As you can see, there is more to a QUAD than the average comment open top 4 wheel utility vehicle! Happy editing!