Z-SCAN11

This document covers the following topics:


Description

Search for a specific character string (search value) in a document.

A scan of the search value can be made in the description, body of document, cover notes, enclosed documents and attached notes, depending upon the value(s) defined in parameter Items-to-scan.

Only documents and enclosed documents with a document format of either 0 (Txt) or 1 (Cnf) are scanned.

This subprogram first searches the description, then cover note text, body of document, text of enclosed documents and lastly, attached notes.

This subprogram does not return search values which exceed more than one line. For example, if an instance of the search value, John Eshberry, begins on line 22 and continues onto line 23, this instance is not returned.

If you mark the parameter Search-by-pattern, you can define the search value as a pattern. One of the following symbols can then be defined in the search value:

  • Period (.), question mark (?) or underscore (_). These symbols are used when a single position is to be ignored. For example, if the search value C?????M is defined, the strings CONFORM, Calcium and Centrum may be returned.

  • Asterisk (*) or percentage symbol (%). These symbols are used when multiple positions are to be ignored. For example, if the search value C*M is defined, the strings Calm, CD-ROM, Cocopalm and also Document may be returned.

The Search-by-pattern logic is based on the EXAMINE statement and its PATTERN option. For further information, see the Natural documentation.

If no occurrence of the search value is found, code 90 is returned.

Each line of text that contains the search value is returned in the Text-table array.

This subprogram should be invoked iteratively until the return code 77 indicates that the document including all cover notes, enclosures and attached notes has been read.

Notes:

  1. To return an item that is stored in the folder Inbasket, Outbasket or Wastebasket, you must pass the ISN which has been returned from a previous API subprogram.
  2. If a document does not have a name (i.e. if the document is identified by its description), it can only be returned using the ISN.

Parameters

Parameter Format In Out Remarks
Return-code N2 O X Input -1: no ET.
Cabinet A8 R   The cabinet which contains the document to be scanned.
Password A8 R   The password of the above cabinet.
Document-name A32 R*   The name of the document that you want to scan. Either Document-name or ISN, not both.
ISN P10 R*   The ISN of document that you want to scan. Either ISN or Document-name, not both.
Search-value A32 R   Character string to be searched in the document.
Search-with-delimiters A1 O   If marked, the search is restricted to whole words (i.e. a character string that is not delimited by blanks or any alphanumeric character). If not marked, each character string which matches the search value is found, regardless of the characters directly before or after the string.
Search-by-pattern A1 O   If marked, Search-value is used as a pattern. In this case, certain characters in the search value (period, question mark, underscore, asterisk and percentage symbol) indicate the position(s) to be ignored.
Search-case-sensitive A1 O   If marked, the search is case-sensitive. If not marked, both upper-case and lower-case characters are found.
Items-to-scan A5 R   The part(s) of the document to be scanned: D=description, B=body of the document, C=cover note, E=enclosed document, N=attached note. For example, DBC means that only description, body of the document and cover note are scanned.
Document-format A1   X Format of the body of the document. See Document Formats.
Lines-in-text-table P2   X Number of filled lines returned in the parameter Text-table with the current subprogram call.
Text-table (20)
  Scanned-document-item A1   X D=description, B=body of the document, C=cover note, E=enclosed document, N=attached note.
  Item-sequential-number P3   X The sequence number for both the description and the body of the document is 1. For all other items of the document , the sequence number of the cover note, enclosed document or attached note is returned.
  Line-sequential-number P7   X Internal sequential line number for an item. For document text, this is the line number that appears in the "Display Document" screen.
  Number-of-found-strings P3   X Number of times, a string is found in this line.
  Text-line A250   X Line of text in which the search string is found.
Work-parameter-1 A240     For internal use. See The Work Parameter.
Work-parameter-2 A91     For internal use. See The Work Parameter.

Return Codes

00 Success
02 Invalid cabinet name or - in batch mode only - locked cabinet
03 Password incorrect
04 ISN was not found
08 Supply either ISN or name, not both
09 ISN does not point to correct object
15 Invalid administrator status
51 Invalid name
53 Requested object does not exist
57 Document contains no text
77 End of object
90 Incorrect item
91 Character string not found
92 Supply search value

Subprograms

Z-120
Z-122
Z-123
Z-165
Z-175
Z-194
Z-197
Z-222
Z-223
Z-400
Z-401
Z-1200&0

Example

0010 *
0020 * Search for a text string in all documents of a cabinet
0030 *
0040 *
0050 DEFINE DATA LOCAL
0060 1 DIS-RETURN-CODE        (N2)
0070 1 CABINET                (A8)
0080 1 PASSWORD               (A8)
0090 1 FOLDER-NAME            (A15)
0100 1 FILE-NAME              (A15)
0110 1 FILE-NUMBER            (N5)
0120 1 FOLDER-NUMBER          (N5)
0130 1 FOLDER-SEQUENCE        (N1)
0140 1 START-VALUE            (A32)
0150 1 NUMBER                 (N2)
0160 1 DOCUMENT-TABLE         (1:20)
0170   2 ISN                  (P08)
0180   2 DOCUMENT-NAME        (A32)
0190   2 DESCRIPTION          (A60)
0200   2 DOCUMENT-FORMAT      (A1)
0210   2 STORED-IN-FILE       (A15)
0220   2 DATE-FIELD           (N8)
0230   2 NAME-SENT-TO/BY      (A20)
0240   2 MAILCOUNT            (N7)
0250 1 WORK-PARAMETER         (A49)
0260 *
0270 1 SCAN-RETURN-CODE          (N2)
0280 1 SCAN-DOCUMENT-NAME        (A32)
0290 1 SCAN-ISN                  (P10)
0300 1 SEARCH-VALUE              (A32)
0310 1 ITEMS-TO-SCAN             (A5)
0320 1 SEARCH-WITH-DELIMITERS    (A1)
0330 1 SEARCH-BY-PATTERN         (A1)
0340 1 SEARCH-CASE-SENSITIVE     (A1)
0350 1 SCAN-DOCUMENT-FORMAT      (A1)
0360 1 LINES-IN-TEXT-TABLE       (P2)
0370 1 TEXT-TABLE                (1:20)
0380   2 SCANNED-DOCUMENT-ITEM   (A1)
0390   2 ITEM-SEQUENTIAL-NUMBER  (P3)
0400   2 LINE-SEQUENTIAL-NUMBER  (P7)
0410   2 NUMBER-OF-FOUND-STRINGS (P3)
0420   2 TEXT-LINE               (A250)
0430 1 WORK-PAR-1                (A240)
0440 1 WORK-PAR-2                (A91)
0450 *
0460 1 #INX1                     (N2)
0470 1 #INX2                     (N2)
0480 1 FIRST-IN-DOCUMENT         (L)
0490 1 STRING-FOUND              (L)
0500 END-DEFINE
0510 *
0520 INPUT (AD=I)
0530   'CABINET' CABINET /
0540   'PASSWORD' PASSWORD /
0550   'SEARCH VALUE' SEARCH-VALUE /
0560   'ITEMS TO SCAN' ITEMS-TO-SCAN /
0570 *
0580 MOVE TRUE TO STRING-FOUND
0590 REPEAT UNTIL DIS-RETURN-CODE EQ 77
0600   CALLNAT 'Z-DIS11'
0610     DIS-RETURN-CODE
0620     CABINET
0630     PASSWORD
0640     FOLDER-NAME
0650     FILE-NAME
0660     FOLDER-NUMBER
0670     FILE-NUMBER
0680     FOLDER-SEQUENCE
0690     START-VALUE
0700     NUMBER
0710     DOCUMENT-TABLE (*)
0720     WORK-PARAMETER
0730   IF DIS-RETURN-CODE NE 0 AND DIS-RETURN-CODE NE 77
0740     WRITE 'Z-DIS11 interrupted. Error code' DIS-RETURN-CODE
0750     STOP
0760   END-IF
0770 *
0780   FOR #INX1=1 TO 20
0790     IF ISN (#INX1) NE 0 THEN
0800       MOVE ISN (#INX1) TO SCAN-ISN
0810       MOVE TRUE TO FIRST-IN-DOCUMENT
0820 *
0830       REPEAT UNTIL SCAN-RETURN-CODE EQ 77
0840         CALLNAT 'Z-SCAN11'
0850           SCAN-RETURN-CODE
0860           CABINET
0870           PASSWORD
0880           SCAN-DOCUMENT-NAME
0890           SCAN-ISN
0900           SEARCH-VALUE
0910           SEARCH-WITH-DELIMITERS
0920           SEARCH-BY-PATTERN
0930           SEARCH-CASE-SENSITIVE
0940           ITEMS-TO-SCAN
0950           SCAN-DOCUMENT-FORMAT
0960           LINES-IN-TEXT-TABLE
0970           TEXT-TABLE (*)
0980           WORK-PAR-1
0990           WORK-PAR-2
1000 *
1010         DECIDE ON FIRST VALUE OF SCAN-RETURN-CODE
1020           VALUE 0, 77
1030             IF FIRST-IN-DOCUMENT
1040               WRITE (AD=I) / '-' (79) / 'String FOUND in: Document'
1050                 DOCUMENT-NAME (#INX1) (AL=21) '(see text below)'
1060               MOVE TRUE TO STRING-FOUND
1070               MOVE FALSE TO FIRST-IN-DOCUMENT
1080             END-IF
1090             FOR #INX2 1 LINES-IN-TEXT-TABLE
1100               WRITE TEXT-LINE (#INX2) (AL=79)
1110             END-FOR
1120           VALUE 91, 57
1130             IF STRING-FOUND
1140               WRITE / '-' (79) / 'String NOT FOUND in:'
1150               MOVE FALSE TO STRING-FOUND
1160             END-IF
1170             WRITE (AD=I) 25T 'Document' DOCUMENT-NAME (#INX1)(AL=21)
1180             ESCAPE BOTTOM
1190           NONE VALUE
1200             WRITE 'Z-SCAN11 interrupted. Error code' SCAN-RETURN-CODE
1210             STOP
1220         END-DECIDE
1230 *
1240       END-REPEAT
1250       RESET SCAN-RETURN-CODE SCAN-DOCUMENT-NAME WORK-PAR-1 WORK-PAR-2
1260     END-IF
1270   END-FOR
1280 END-REPEAT
1290 END