Example of condition names, COBOL Programming

Example of condition names:

The illustration below is of the use of the condition names

 77  MARITAL-STATUS     PIC    9

  88  SINGLE    VALUE    IS     ZERO

  88  MARRIED    VALUE    IS    1.

  88  WIDOWED    VALUE    IS    2.

  88  DIVORCED    VALUE    IS    3.

  88  ONCE-MARRIED  VALUE  ARE    1, 2, 3.


It might be noted that 6 condition names have been defined here. All of them are related with the conditional variable MARITAL - STATUS. If at a point of time, the MARITAL STATUS gets the value of 2, then the condition names WIDOWED, ONCE-MARRIED & VALID-STATUS will become true and others will become false.

The condition names can be used as a condition. Therefore in PROCEDURE DIVISION we may have statements, such as:




In (a) statement SUBTRACT 125 FROM DEDUCTIONS will be executed if the MARITAL-STATUS is equivalent to zero. Likewise, in (b) the ADD statement will be executed only when the MARITAL - STATUS is equivalent to 1, 2 or 3 and in  (c) the control goes to the procedure ERROR-IN - STATUS only when MARITAL-STATUS has a value other than the 0, 1, 2 or 3. As in (c) a condition name can be preceding by NOT to point the negation of the condition.

The format for the condition - name condition is

  [NOT] condition - name

It is very important to note the usefulness of a condition name. Whenever a condition name specifies a single value for the conditional variable, the condition name is equal to the relational condition. For illustration, in (a) above the condition name SINGLE is equal to the relational condition MARITAL-STATUS =0. Even when the condition name identifies more than one value for the conditional variable, then condition name can be replaced by an equivalent compound condition. Therefore it may not be absolutely essential to make use of the condition names. However it may not be absolutely essential to make use of the condition names. The main benefit of a condition name is that it increases the readability of the statement which uses it. Surely, the use of the condition name WIDOWED conveys more information to a reader of the program than the use of the relational condition MARITAL-

STATUS =2. Specifically for this cause, it is suggested that whenever possible, the meaningful condition names must be used in a program.

Posted Date: 10/17/2012 1:44:41 AM | Location : United States

Related Discussions:- Example of condition names, Assignment Help, Ask Question on Example of condition names, Get Answer, Expert's Help, Example of condition names Discussions

Write discussion on Example of condition names
Your posts are moderated
Related Questions
SEQUENTIAL FILE CREATION AND REWRITING: We have to write a program to create a student file with just two fields: sno i.e. Student Number and same i.e. Student Name. Add a few

REWRITE STATEMENT: As in the situation of a relative file, the REWRITE statement needs that the file should be opened in the I-O mode, and if the SEQENTIAL access mode is spec

RULES FOR INDEXED TABLES: The rules of indexing a table with an INDEXED phrase are as shown below: (1) If indexing is completed for any one level of a table, then indexing

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:

Abbreviation: The Consecutive relational conditions in a compound condition can be abbreviated in many cases as shown: (i) When the subjects in the consecutive relational c

Group Item as Operand in the Relational Condition: Whenever an operand of a relational condition is the group item, the item is then considered to be an alphanumeric field. Th

Transaction file : A transaction file is a file which contains new records those changes to old records which are used to update the master file. The problem of file updatio

Second form of Divide verb: The second form of this verb is as shown below: In this situation the identifier-1 or numeric- literal-1 will be divided by identifier-2 or

Example of Redefines clause: This illustration describes a sales record that may either contain the total amount of sale or the quantity (QTY) and UNIT-PRICE. The aim of such

PROCEDURE DIVISION statements for the indexed files: All the statements which are available for a relative file are also available for an indexed file. READ STTATEMENT :