SCAN Description

I've written 4 file scan programs - because I like doing that. And, at my Methuselahlistic age of 81, it's what I'm capable of. (Maybe.) The history is that in the '70s, my boss wanted to scan a multi-reel tape file for something, maybe his name. He wrote an inefficient COBOL program that locked up the 360/95. I wrote a program that allowed a user to code multiple strings in the PARM field, and it would search for all the strings, based on the first character of each, which worked well for what he wanted.

The problem with that was that if you wanted to search for " ABC" then you'd do a compare every time you found a blank. Today, I'd search for "B" because it occurs less often than "A" and slightly less often than "C". This routine is, of course, in all 4 programs.

I'm testing on Z390.ORG simulator, which does some things differently. Most important is that if you use any of these programs, you'll need to change the DCBs. And you should use the OPENEXIT that's coded just before the DCBs to 'soft code' RECFM and LRECL into the //OUT file (from the //IN file). And you'll need the DCBD macro at the end. I think everything else works.


Today the programs only do sequential files, because that's what's available on Z390.ORG
It'd be nice to also do PDS files, but that development needs to be done in an MVS environment.

The 4 related programs are:

SCAN1 which scans a file for a single character string, coded in the PARM field. BUT, it can also edit, replacing that string with another of the same length. I started SCAN1 as a takeoff from SCANFAST, for just 1 argument, but then added the EDIT function, and more to make it 'pretty'. The description in the source should be adequate.

https://sites.google.com/site/linlyons/scan1

SCANFAST (I will eventually change the name to FASTSCAN, because I like that better) is the most basic, and runs fastest for what it does, which is scan a file, looking for multiple character strings specified in the PARM field. It is faster than the other two programs because it searches for all strings simultaneously. I've changed a couple things, and added some, but I think that what needs to happen is for someone in a 'real' MVS environment to load and test it. You have my permission to do that. Please let me know when you do.

https://sites.google.com/site/linlyons/scanfast

SCANSTR scans a file for character strings, using IF, AND, OR logic to select the strings to copy or display records. SCANSTR can also edit records. It's kind of a middle child, and I don't know if I'll work on it much more, or promote it.

https://sites.google.com/site/linlyons/scanstr

MYSCAN is the most complete. It can scan a file, EDIT records, and create various output files with subsets of records from the input file.
Still testing.

All 4 programs save strings in tables, and determine which character in each string is likely to occur least often in the source file, and then use TRT to search for that character. SCANFAST only uses the PARM field for control input, while the others both use PARM and SYSIN.

There's a 5th program, SCANFREQ that looks at your data, and creates the table of character frequency that's used to speed up all 4 programs. If you look at the source for SCANFREQ, it'll tell you how to use it.

https://sites.google.com/site/linlyons/scanfreq

Note, I did consider incorporating a dynamic frequency table, but think that most uses will be for smaller files, and a frequency table that's 'close' will be good enough. You're free to do whatever you'd like.

SCANFAST has about a page of description at the beginning of the program. I believe it's fairly complete, but if not, please let me know. At my age, I forget lots of things.


------------------------------------------------------------------------------


This is the internal description from SCAN1:

SCAN1 (EDIT2) V01.02 09/03/22 09.16

SCAN1 WAS WORKING AT 200 LINES OF CODE, AND 2K

ADDING QUOTES, OPIONS, AND TOTALS, NOW 1,000 LINES AND 7K


//SCAN EXEC PGM=SCAN1,PARM="MVC" COPY RECS CONTAINING MVC

//STEPLIB DD DISP=SHR,DSN=

//SYSPRINT DD SYSOUT=*

//IN DD DISP=SHR,DSN=

//OUT DD DISP=(,CATLG),DSN=


PARM=DOC PRINT PROGRAM DESCRIPTION (MUST BE FIRST IN PARM

=COPY ALL RECORDS

=LIST PRINTS RECORDS ON //SYSPRINT

=TEST PRINT LOCATIONS OF (ERROR/ALL) MSGS

=EDIT (REPLACE, REALLY) ONE STRING WITH ANOTHER OF SAME LEN

=EDITALL REPLACE ALL STRINGS IN THE RECORD

||| ALLOWS MULTIPLE (TEST) RUNS, USING SAME FILE, AND

DIFFERENT PARM FIELDS. I PUT THE ||| IN FOR TESTING,

AND LEFT IT. EG: IF YOU CODE ...


PARM='MVC|||EDIT,MVC,XYZ|||EDITALL,MVC,XYZ|||EDITALL,MV,MM'

THE FIRST PASS WILL FIND ALL RECORDS CONTAINING MVC

THE SECOND PASS WILL CHANGE THE FIRST MVC TO XYZ

THE THIRD PASS WILL CHANGE EVERY MVC IN EACH RECORD.

THE FORTH PASS WILL CHANGE MVVVVVVVV TO MMMMMMMMM


PARM="DOC,COPY,EDIT,MVC,YES" DOC,MUST BE FIRST, COPY ENTIRE FILE

CHANGE FIRST MVC YES IN EACH RECORD

PARM="DOC,MVC" PRINT DOC, FIND MVC RECORDS.

PARM="EDIT,MVC,WER" SELECT RECS CONTAINING MVC, CHANGE TO WER

PARM="COPY,MVC" COPY ALL RECS,COUNT RECORDS CONTAINING MVC

PARM="COPY,EDIT,MVC,YES" COPY ALL RECORDS, CHANGE MVC TO YES

(THE EDIT STRINGS MUST BE THE SAME LENGTH)

PARM="SAVE|||PARM|||SAVEPARM|||EDIT,SAVE,OOPS"

||| IS A PARM SEPARATER. THIS SCANS THE SAME //IN FILE

4 TIMES LOOKING FOR "SAVE", THEN "PARM", THEN

"SAVEPARM" AND LAST EDITING "SAVE" TO "OOPS"


CAN HAVE QUOTED STRINGS IN PARM. EG


PARM C"PUT,LINE" FIND PUT,LINE STRINGS.

PARM EDIT,C"PUT",C"NOP" FIND AND CHANGE PUT TO NOP

AGAIN, STRINGS MUST BE SAME LENGTH

AND YOU CAN HAVE PACKED AND HEX STRINGS. EG:

X"C1C2C3" MUST HAVE EVEN # HEX DIGITS

P"123" PACKED 123 LENGTH =2

P"-1234" PACKED NEGATIVE -1234 LENGTH =3

FOR PACKED #S, THE SIGN MUST BE ###C OR ###D (MINUS)

NOT ###F, WHICH IS USED FOR PRINTING.


IF YOU ARE DOING AN EDIT, THEN EITHER BOTH OR

NEITHER STRINGS MUST BE QUOTED. AND SAME LENGTH.


ONE OF A SET OF SCAN PROGRAMS:

FASTSCAN SCAN FOR MULTIPLE STRINGS IN 1 PASS OF FILE.

MYSCAN SCAN/EDIT WITH SEVERAL OPTIONS

SCANFREQ READ A FILE, CALC CHAR FREQUENCY.

SCAN1 ONLY 1 ARGUMENT, SPECIFIED IN PARM FIELD