Rules for search verb, COBOL Programming

RULES FOR SEARCH VERB:

The rules apply for the SEARCH verb is as shown below:

(1) The SEARCH verb can be applied only to a table that has the OCCURS clause and INDEXED phrase. The identifier-1 specifies the table to be searched and it should not be indexed or subscripted.

(2) Before the use of the SEARCH verb, the index should have some initial value. The initial value should not exceed the size of the table. If it exceeds, the search is finished instantly. Then if the AT END clause is identified, statements after AT END will be executed; or else the control passes to the next sentence.

(3) If the AT END condition is identified, as in the case of the first illustration, and if the element that is being searched is not found in the table, the statement subsequent to the AT END clause will be executed if statements after AT END do not transfer the control somewhere else in the program. On another hand, if AT END is not used and the end of the table is arrived, the control will be automatically transferred to the next sentence.

(4) The SEARCH verb begins with the initial value of the index and tests whether the conditions stated in the WHEN clauses have been satisfied or not. If not any of the conditions are satisfied the index is incremented automatically by 1. The procedure is continued until the index values exceed the size of the table, the statements subsequent the condition in the relevant WHEN clauses are executed. If such statements do not transfer the control somewhere else, after their execution, it is transferred to the later sentence. The value of the index remains set at the point where the condition has been satisfied.

(5) Connected with the VARYING option, the identifier-2 can be a data, an integral elementary item or the index data item (explained with USAGE AS INDEX CLAUSE). The aim of specifying the VARYING clause is that the identifier-2 is also incremented each time the index of the table is incremented.

Posted Date: 10/18/2012 1:57:49 AM | Location : United States







Related Discussions:- Rules for search verb, Assignment Help, Ask Question on Rules for search verb, Get Answer, Expert's Help, Rules for search verb Discussions

Write discussion on Rules for search verb
Your posts are moderated
Related Questions
CLOSE STATEMENT: When the processing of a file is completed, then the file may be closed. This is completed with the help of the CLOSE-verb. The form of the CLOSE statement is

PROGRAM FOR SIMPLE PERFORM: We have to write a program to elaborate simple PERFORM statement Identification division. Program- id.  Perf1. Environment division. Da

ADD VERB: The ADD Verb can be used to find the sum of two or more numbers and to store the sum.  The ADD verb takes any one of the two forms as shown below:

Illustration of nested if statement: Consider the nested sentence which is as shown below: The IF-ELSE pairs in this sentence can be detected by applying the rule whic

Column and Field in COBOL program: In COBOL there are 2 types of entries termed as margin A and margin B entries. The Margin A entries start from the column 8, 9, 10 or 11 and

File- Section &Working-Storage Section: a) FILE SECTION: The FILE SECTION includes the explanation of all data items that must be read from or written onto some external

Structure of a COBOL Program: Every COBOL program should have the 4 divisions in the order in which they are specified below: 1. Identification division 2. Environment D

Illustration of the abbreviation: A few illustration of the abbreviation are given below: Illustration: The compound condition  AMOUNT GREATER THAN 499 AND AMOUNT L

Comparison of Nonnumeric Operands: A nonnumeric operand can be compared to the other nonnumeric operand according to the rules as shown below: (i) Fields of Equal Sizes:

INPUT-OUTPUT SECTION: This section holds information regarding the files to be used in the program. There are 2 paragraphs in this section- FILE-CONTROL & I-O-CONTROL. The