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
What is the difference b/w index and subscript? Subscript indicates to the array occurrence whereas index is the displacement (in no of bytes) from the beginning of the array.

SIGN CONDITION:   The sign condition establishes whether or not the algebraic value of an operand is negative, positive or zero. The operand can be either the numeric identif

Data Names and Identifiers:   The Data name provides reference to the storage space in the memory where the real value is stored. This value takes part in the operation whene

Examples - Edit characters for numeric data: The following illustration illustrates the use of Z editing characters. The character b is used to indicate the space character an

RELATIONAL CONDITION:   We know that a relational condition specifies a comparison between two operands and has the form.     Operand-1    relational-operator   operand-2

PROGRAM FOR ADD CORRESPONDING: We have to write a simple program to demonstrate Add Corresponding.   identification division.   program- id.   environment division.

OCCURS CLAUSE - PROGRAM: We have to write a program to elaborate occurs clause. Get names and marks of the students and show them on the screen.   identification division.

Program for Sequential File Creation & Rewriting  We have to write a program to create a Length file with just two fields: l (Length) and l-c (Length-Code). Add a few records.

PROGRAM FOR MULTIPLY VERB: We have to write a simple program to elaborate MULTIPLY verb. You can also use the edit characters in the program. Identification division. Pr

FD Entry for variable-length Records: The RECORDS CONTAINS and BLOCK CONTAINS clause are quite dissimilar in the case of files with variable- length records. The syntax of the