Skip to main content

ESEARCH has been around for a long time, PESEARCH has been designed to expand on / replace the ESEARCH utility to allow Python RegEx Search Patterns and the ability for case insenstive searchs.

 

Installation Steps

  • Remove the .txt extensions from the attachments
  • To install use the attached PESEARCH UniBasic program and Pesearch python function.
  • Compile and Catalog the PESEARCH program.
  • Install the Pesearch python script into a python location that can be located by UniVerse / UniData.

 

Extra Steps for UniData

If you are using UniData please also see the related article around to avoid running any LOGIN paragraph a second time and why this has to been done. In summary PESEARCH sets @USER.RETURN.CODE to "PY" and back to any previous setting so that @USER.RETURN.CODE can be tested in the LOGIN paragraph.

LOGIN:

PA

IF @USER.RETURN.CODE = "PY" THEN GO 200

200:

 

Extra Steps for UniVerse

By default UniVerse will not keep a select list active when a basic program completes (UniData does).  In order to get PESEARCH to function as expected in UniVerse you need to modify the CATALOG entry for the program to have the K dispatch option.

 

Default VOC entry on UV for PESEARCH

001: V

002: *XDEMO*PESEARCH

003: B

004: BN

 

With the K dispatch switch Modifiction

001: V

002: *XDEMO*PESEARCH

003: B

004: BNK

 

Syntax and usage

Program designed to expand on the old ESEARCH tool in UniData and is designed to use power of RegEx search function of python. Version 1.0 is the Initial Release version.

 

Syntax PESEARCH filename list of record ids | selection criteria (options

 

Note: The list of record ids or selection criteria need to be specified in the same way as in a SELECT statement (i.e., ids in quotes)

 

[record ids] list of record ids to search (each record id should be in quotes)

[selection criteria] the selection criteria for the file

If no record ids or selection criteria are supplied every record is checked

 

Options

  • N - Selected Records must not contain any of the specified searches
  • I - Search is case insensitive
  • D - Display the ids of records as they are found
  • S - Display only the ids of the records and do not form a select list
  • A - Selected Records must match all conditions

Once the initial selection criteria and options have been checked and processed you will be prompted for ‘String or Pattern Search’. You can enter as many criteria as you require. The list is terminated with a null entry. The string or pattern search will be passed to the python script and must be specified to work with a re.search function.

 

Search Pattern Examples

ball – finds the string ball

\bball\b - find the exact word for ball

\w{8}  - eight letter word

(\d{3})-(\d{3})-(\d{4}) – A string match 3N’-‘3N’-‘4N in the U2 World

There are hundreds of possibilities

 

Examples

:PESEARCH VOC (I

Selecting All of File

Checking 1142 Records

Option Declared

Case Insensitive

 

String or Pattern Search jonathan

String or Pattern Search

 

Records Checked 1,142

Records Matched 3

Time Taken      79 ms

 

3 records selected to list 0.

 

>

 

:PESEARCH VOC

Selecting All of File

Checking 1143 Records

No Options Declared

 

String or Pattern Search jonathan

String or Pattern Search

 

Records Checked 1,143

Records Matched 0

Time Taken      78 ms

 

0 record(s) selected.

 

:PESEARCH VOC WITH @ID LIKE "...H..." (I

Selection Critera WITH @ID LIKE "...H..."

Checking 115 Records

Option Declared

Case Insensitive

 

String or Pattern Search jonathan

String or Pattern Search

 

Records Checked 115

Records Matched 1

Time Taken      63 ms

 

1 records selected to list 0.

 

:PESEARCH VOC

Selecting All of File

Checking 1142 Records

No Options Declared

 

String or Pattern Search \w{8}

String or Pattern Search

 

Records Checked 1,142

Records Matched 437

Time Taken      79 ms

 

437 records selected to list 0.

 

Related Articles

Python-function-returns-incorrect-results-using-u2py-and-or-the-unexpected-running-of-the-LOGIN-paragraph

Be the first to reply!