1 / 15

COBOL (COMMON BUSINESS ORIENTED LANGUAGE)

COBOL (COMMON BUSINESS ORIENTED LANGUAGE). Overview. SEQUENCE CONTROL verbs. GO TO IF . . . THEN . . . PERFORM EVALUATE STOP RUN. GO TO Verb. Syntax-1 GO TO paragraph-name. Example GO TO READ-PARA. GO TO. Syntax-2

oberon
Download Presentation

COBOL (COMMON BUSINESS ORIENTED LANGUAGE)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COBOL (COMMON BUSINESS ORIENTED LANGUAGE) Overview

  2. SEQUENCE CONTROL verbs • GO TO • IF . . . THEN . . . • PERFORM • EVALUATE • STOP RUN

  3. GO TO Verb • Syntax-1GO TO paragraph-name. • ExampleGO TO READ-PARA.

  4. GO TO . . • Syntax-2 GO TO paragraph-name-1 [paragraph-name-2 ]Example GO TO INSERT-PARA, UPDATE-PARA, DELETE-PARA DEPENDING ON TRANS-CODE.

  5. IF statement • Syntax-1 IF condition [ THEN ] {statement-1, NEXT SENTENCE} [ELSE {statement-2, NEXT SENTENCE}] [ END-IF ]. • Examples (1) IF MARKS >= 80 THEN MOVE ‘A’ TO GRADE ELSE MOVE ‘B’ TO GRADE END-IF. (2) IF NOT OK-BALANCE THEN MOVE 2 TO BALANCE-CODE ELSE NEXT-SENTENCE END-IF

  6. CONDITION • The condition can be any one of the conditions • Simple Conditions • Relation Conditions • Class Conditions • Sign Conditions • Compound Conditions • Condition Names

  7. Relation Conditions

  8. IF statement • Syntax-2 ( Nested IF ) IF condition-1 [ THEN ] statement-1 ELSE IF condition-2 [ THEN ] statement-2 ELSE statement-3 END-IF END-IF. Example IF ( Var1 < 10 ) THEN DISPLAY “Zero” ELSE IF Var2 = 14 THEN DISPLAY “First” ELSE DISPLAY “Second” END-IF END-IF.

  9. Sign condition • Syntax ExampleIF DISCRIMINANT IS NEGATIVE THEN DISPLAY “The roots are imaginary”.

  10. Class condition • Syntax Example IF REGNO IS NOT NUMERIC THEN DISPLAY “Records will not be sorted”.

  11. Compound Condition • Syntax Condition-1 { AND, OR } Condition-2 • Examples(1) IF PERCENT > 80 AND TOTAL > 480 THEN MOVE ‘A’ TO GRADE.(2) IF ROW-NUMBER > 24 OR COLUMN > 80 THEN DISPLAY “Page Error ! “.

  12. Defining Condition Names. • Condition Names are defined using the special level number 88 in the DATA DIVISION of a COBOL program. • They are defined immediately after the definition of the data item with which they are associated with. • We can use Condition Names for a group as well as an elementary item. • A condition name takes the value TRUE or FALSE depending on the value of the data item with which it is associated. The VALUE clause of the associated data item is used to identifythe values which make the Condition Name TRUE.

  13. Condition Names • Are essentially boolean variables. • Are always associated with data names called condition variables. • Is defined in the DATA DIVISION with levelnumber 88. • Syntax88 condition-name {VALUE IS, VALUES ARE } literal-1 [ { THRU, THROUGH } literal-2 ].

  14. Condition-Names .. example 01 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 VALUES ARE 1, 2, 3. 88 VALID-STATUS VALUES ARE 0 THRU 3. Condition Names PROCEDURE DIVISION Statements.DISPLAY ‘ENTER MARTIAL STATUS.:’. ACCEPT MARITAL-STATUS. IF SINGLE SUBTRACT 125 FROM DEDUCTIONS. IF ONCE-MARRIED ADD 300 TO SPECIAL-PAY. IF MARRIED PERFORM B000-MARRIAGE-GIFT. Martial-status = 0 Martial-status = 2 Martial-status = 1

  15. Thank You Overview

More Related