Example of condition names, COBOL Programming

Assignment Help:

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.

  88  VALID-STATUS  VALUE  ARE    0 THRU 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:

(a)  IF SINGLE SUBTRACT 125 FROM DEDUCTIONS.

(b)  IF ONCE - MARRIED ADD 32 TO SPECIAL-PAY.

(c)  IF NOT VALID - STATUS GO TO ERROR - IN - STATUS.

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.


Related Discussions:- Example of condition names

Close statement - sequential files, CLOSE statement: The simplified sy...

CLOSE statement: The simplified syntax of the CLOSE statement is as shown below:   CLOSE          file-name-1   [WITH   LOCK   ]                         [  , file-

Buffers - file characteristics, Buffers: The Modern computers are able...

Buffers: The Modern computers are able of handling I-O operations independent of the CPU by means of the hardware termed as data channel. For illustration, if two buffers a

Currency sign - edit characters for numeric data, Currency Sign - edit char...

Currency Sign - edit characters for numeric data: $ (Currency Sign): The single currency sign can appear at the leftmost place of a picture. In that situation the $ cha

Perform with varying option, PERFORM WITH VARYING OPTION: The format i...

PERFORM WITH VARYING OPTION: The format is as shown below:

Picture specification - picture clause, PICTURE specification: The siz...

PICTURE specification: The size of a group item is equivalent to the total of the sizes of all the subordinate elementary items. The group item class is alphanumeric. The i

Program for perform - until, PROGRAM FOR PERFORM ...UNTIL We have to w...

PROGRAM FOR PERFORM ...UNTIL We have to write a program to find the sum of "n" natural numbers. Identification division. Program- id. PerfUntil. Environment division.

Sign condition - cobol programming, SIGN CONDITION:   The sign condit...

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

File characteristics, FILE CHARACTERISTICS: The task of file handling ...

FILE CHARACTERISTICS: The task of file handling is the responsibility of the system software termed as IOCS (Input-Output control system). Record Size: We know that th

Indexed sequential files, INDEXED SEQUENTIAL FILES: In the indexed seq...

INDEXED SEQUENTIAL FILES: In the indexed sequential files which are also known as indexed files, the records are stored in the sequence order generally in ascending order. In

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd