Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask COBOL Expert


Home >> COBOL

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.

COBOL, Programming

  • Category:- COBOL
  • Reference No.:- M9512058

Have any Question?


Related Questions in COBOL

Write a program that will provide a list of their employees

Write a program that will provide a list of their employees with the following information: Field Size Type Additional Information Employee Number 5 Alphanumeric Employee Name 20 Alphanumeric Position Title (PT) 10 Alpha ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As