A month or so ago, at 2am, I realized that there was a better / faster way to determine the least frequently used character in a string. I use a routine to do this when I'm searching for a character string. For instance, searching for the string "EXAMPLE" goes much quicker when you search for "X" rather than "E". But for the compare, you have to backup 1 byte. If you were searching for "REALIZE" then you have to back up more. Next morning I wrote and tested my idea, and it worked well.
Over many years, I've written several string search programs, in various forms, to search for character strings, starting in the '70s when I wrote something for my boss who wanted that ability. To some degree, I work on such to keep my mind active, and thinking. In any case, I've written 2 programs, and am working on a 3rd, which is much more complicated. The 2 programs are:
QSTRING1 -- search for a single string, character or hex, specified in the PARM field. It only uses the PARM field, and does not consider SYSIN. Records containing the string are written to //OUT
QSTRING --- search for one or more strings, specified in either the PARM field, or the //SYSIN file. When a string is found, then the record is written to //OUT##. The SYSPRINT file displays the strings, the file names, and the number of times records are written. When searching, and a string is found, then the search must continue, because there may be more than 1 string in a record. And, if string occurs multiple times, we only want to write it the first time, not again afterward.
QSTRING1 is the simpler of the two, and probably runs minisculely faster.
QSTRING allows several search strings, but the logic is similar. In both cases, the program will find the least frequently used character and to a TRT search for that character and then a CLC compare for the string. When QSTRING is looking for multiple strings, then the TRT instruction looks for the least frequent character in all of them, and then tests the strings that contain the character found.
Note, there is a 3rd program I'm working on, tentatively titled SPLITOUT, but it's both more complicated, and not nearly finished yet. But it will be one of the set.
=================================================
The code for QSTRING1 is in:
https://sites.google.com/site/linlyons/qstring1-code
For QSTRING1, the JCL looks like:
//SCAN EXEC PGM=SCAN1,PARM='ABCD' or 'C"ABCD" or 'X"C1C2C3C4"'
//STEPLIB DD DISP=SHR,DSN=
//SYSPRINT DD SYSOUT=*
//IN DD DISP=SHR,DSN=your file
//OUT DD DISP=(,CATLG),DSN=your file ,ETC
And the report looks like:
QSTRING1 ASM V01.01 05/10/26 16.36 linlyons@yahoo.com
COPY RECORDS CONTAINING STRING SPECIFIED IN PARM FIELD
SYSPRINT OPENED FOR OUTPUT, RECFM=A0 LRECL=00133
IN OPENED FOR INPUT, RECFM=A0 LRECL=00266
OUT OPENED FOR OUTPUT, RECFM=A0 LRECL=00266
PARM = QSTRIN SCAN FOR 000 Q 005
658 RECORDS READ
17 RECORDS WRITTEN
===========================================
The code for QSTRING (the other program) is in:
https://sites.google.com/site/linlyons/qstring-code
For QSTRING, the JCL looks like:
//SCAN EXEC PGM=QSTRING (NO PARM)
//STEPLIB DD DISP=SHR,DSN= ????
//SYSPRINT DD SYSOUT=*
//IN DD DISP=SHR,DSN= ???
//OUT01 DD ....
//OUT02 DD ....
//OUT03 DD ....
//OUT04 DD ....
//OUT05 DD ....
//OUT06 DD ....
//OUT07 DD ....
//OUT08 DD ....
//OUT09 DD ....
//OUT10 DD ....
//OUT11 DD ....
//OUT12 DD ....
//OUT13 DD ....
//OUT14 DD ....
//OUT15 DD ....
//OUT16 DD ....
//OUT17 DD ....
//SYSIN DD * (note, if col-1=blank, it's a comment)
C'Z390'
C'z390'
C'QSTRING'
C'LICENSE'
C'WARRANTY'
C'EXAMPLE'
C'Users'
C'LLC'
X'C9E3' IT
C'TRT'
C'TR'
X"C3D3C3" CLC
C$TABLE$
X'C1E9' AZ
And the report looks like:
QSTRING V01.01 ASM 05/10/26 14.44 linlyons@yahoo.com
COPY RECORDS CONTAINING 1 OR MORE STRINGS SPECIFIED
SYSPRINT OPENED FOR OUTPUT, RECFM=A0 LRECL=00133
SYSIN OPENED FOR INPUT, RECFM=A0 LRECL=00080
CARD= C'Z390'
CARD= C'z390'
CARD= C'QSTRING'
CARD= C'LICENSE'
CARD= C'WARRANTY'
CARD= C'EXAMPLE'
CARD= C'Users'
CARD= C'LLC'
CARD= X'C9E3' IT
CARD= C'TRT'
CARD= C'TR'
CARD= X"C3D3C3" CLC
CARD= C$TABLE$
CARD= X'C1E9' AZ
SYSIN CLOSED,
001 OUT02 000 003 003 C z z390
002 OUT13 002 002 004 C B TABLE
003 OUT12 000 002 002 X C3 C3D3C3
004 OUT04 002 004 006 C C LICENSE
005 OUT08 002 000 002 C C LLC
006 OUT09 000 001 001 X C9 C9E3
007 OUT03 000 006 006 C Q QSTRING
008 OUT10 001 001 002 C R TRT
009 OUT11 001 000 001 C R TR
010 OUT07 000 004 004 C U Users
011 OUT06 001 005 006 C X EXAMPLE
012 OUT05 007 000 007 C Y WARRANTY
013 OUT14 001 000 001 X E9 C1E9
014 OUT01 000 003 003 C Z Z390
IN OPENED FOR INPUT, RECFM=A0 LRECL=00399
OUT03 OPENED FOR OUTPUT, RECFM=A0 LRECL=00399
OUT11 OPENED FOR OUTPUT, RECFM=A0 LRECL=00399
OUT01 OPENED FOR OUTPUT, RECFM=A0 LRECL=00399
OUT02 OPENED FOR OUTPUT, RECFM=A0 LRECL=00399
OUT14 OPENED FOR OUTPUT, RECFM=A0 LRECL=00399
OUT08 OPENED FOR OUTPUT, RECFM=A0 LRECL=00399
OUT05 OPENED FOR OUTPUT, RECFM=A0 LRECL=00399
OUT04 OPENED FOR OUTPUT, RECFM=A0 LRECL=00399
OUT07 OPENED FOR OUTPUT, RECFM=A0 LRECL=00399
OUT12 OPENED FOR OUTPUT, RECFM=A0 LRECL=00399
OUT09 OPENED FOR OUTPUT, RECFM=A0 LRECL=00399
OUT13 OPENED FOR OUTPUT, RECFM=A0 LRECL=00399
OUT10 OPENED FOR OUTPUT, RECFM=A0 LRECL=00399
IN CLOSED,
RECORDS READ 1,113
STRINGS FOUND 233
OUT02 CLOSED, 06 RECRDS WRITTEN TO OUT02 z390
OUT13 CLOSED, 02 RECRDS WRITTEN TO OUT13 TABLE
OUT12 CLOSED, 21 RECRDS WRITTEN TO OUT12 X C3D3C3
OUT04 CLOSED, 01 RECRDS WRITTEN TO OUT04 LICENSE
OUT08 CLOSED, 01 RECRDS WRITTEN TO OUT08 LLC
OUT09 CLOSED, 44 RECRDS WRITTEN TO OUT09 X C9E3
OUT03 CLOSED, 17 RECRDS WRITTEN TO OUT03 QSTRING
OUT10 CLOSED, 19 RECRDS WRITTEN TO OUT10 TRT
OUT11 CLOSED, 96 RECRDS WRITTEN TO OUT11 TR
OUT07 CLOSED, 01 RECRDS WRITTEN TO OUT07 Users
OUT05 CLOSED, 01 RECRDS WRITTEN TO OUT05 WARRANTY
OUT14 CLOSED, 11 RECRDS WRITTEN TO OUT14 X C1E9
OUT01 CLOSED, 13 RECRDS WRITTEN TO OUT01 Z390