If your assembler program is LE-enabled, you might consider using the C library 
regular expression builtin functions.  For each "Acceptable value" structure 
you would (one time) construct a regular expression consisting of literals for 
fields with values and the regular expression ".+" ("match one or more of any 
character") for fields with asterisk in the first position.  You concatenate 
the elemental regular expressions ("this followed by this followed by this 
..."), then compile each such constructed expression with the regcomp function 
and save the result.  Then for each table element to be checked you use the 
expression match function (I forget the name) passing each compiled regcomp 
pattern in a loop until one of them matches o none of them do.

Other possible regular expressions you may use for asterisk fields could be "[ 
]+|.+" meaning "one or more spaces OR one or more of any character".  Not sure 
if that is better or worse performance than the simpler ".+", but it is an 
alternative.  

I did not check, but Metal C might allow access to the C library regular 
expression functions, and if it does you might consider writing a Metal C 
function to do the searching and matching, or better two such functions, one to 
compile the acceptable expressions and one to search each table element.

And if your assembler program is LE-enabled, you could consider just writing 
the functions in normal C and then call them like any other LE subroutine.

Just trying to think out-of-the-normal-assembler-box here.  Why reinvent the 
tool if it is available for your use?

HTH

Peter

-----Original Message-----
From: IBM Mainframe Assembler List [mailto:[email protected]] On 
Behalf Of [email protected]
Sent: Saturday, June 17, 2017 11:55 AM
To: [email protected]
Subject: Table Searchig with a Mask

Hi everyone

I would like some help in reducing the number of instructions required to 
search a table.
The table is in no particular order, so a Binary Search may not be appropriate 
here.
.
.
I will try to explain this.
.
I have a structure with X number of fields
For this example lets assume:
STRUCTURE    EQU *
USERID       DS CL8 
COMPANY_CODE DS CL4
JOB_NAME     DS CL8
FILE         DS CL8

I also have an Array (table) of Acceptable Values with the same elements   
as my structure.
I can search the table using a single compare for a length of 28.
.
.
However some of the table entries contain an asterisk "*" in the first position 
of 
the respective field. The asterisk means to accept any value from the structure.
For Example:
ARRAY         EQU  *
TUSERID       DC CL8'JOSEPH  '
TCOMPANY_CODE DC CL4'*   '
TJOB_NAME     DC CL8'REPORT  '
TFILE         DC CL8'*       '
.
In order to search the table using a single compare instruction, I would need 
to overlay
the respective elements in the structure with the Asterisk from the 
corresponding element
in the Array Table Entry. 
.
This would mean I would need to compare each element in the ARRAY entry for the 
Asterisk, 
and if present move the corresponding field to the structure.
           CLI TCOMPANY_CODE,=C'*'
           JNE NEXT_ELEMENT
           MVC COMPANY_CODE,TCOMPANY_CODE
.
I prefer not to test each element in the ARRAY for an Asterisk and Move them 
individually 
to the structure, prior to comparing the structure with the Array Entry. 
.
I'm not aware of any instruction that will move selectively all fields
with an Asterisk "*". Which Is what I am looking for, then I can use a single 
move
or four Moves and continue to use a single compare instruction.
.
Again I'm looking for the fewest amount of instructions to accomplish this. 
.
What Alternatives are there ?  
A long time ago I did see someone do something similar with a Translate and 
Test.
But again this is several iterations of TRT and a Move for each Array element.
.

Thank You
Paul D'Angelo
************ 

This message and any attachments are intended only for the use of the addressee 
and may contain information that is privileged and confidential. If the reader 
of the message is not the intended recipient or an authorized representative of 
the intended recipient, you are hereby notified that any dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please notify us immediately by e-mail and delete the message and any 
attachments from your system.

Reply via email to