conditions.. if syntax. simple conditions l relation conditions l class conditions l sign...

26
Condition Condition s. s.

Upload: madison-snow

Post on 17-Dec-2015

233 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Conditions.. IF Syntax.   Simple Conditions l Relation Conditions l Class Conditions l Sign Conditions   Complex Conditions   Condition Names

Conditions. Conditions.

Page 2: Conditions.. IF Syntax.   Simple Conditions l Relation Conditions l Class Conditions l Sign Conditions   Complex Conditions   Condition Names

IF Syntax.IF Syntax.

IF Condition THEN StatementBlock

NEXT SENTENCE

ELSE StatementBlock

NEXT SENTENCE END - IF

Simple Conditions Relation Conditions Class Conditions Sign Conditions

Complex Conditions Condition Names

Simple Conditions Relation Conditions Class Conditions Sign Conditions

Complex Conditions Condition Names

CCONDITION ONDITION TTYPESYPES

Page 3: Conditions.. IF Syntax.   Simple Conditions l Relation Conditions l Class Conditions l Sign Conditions   Complex Conditions   Condition Names

Relation ConditionsRelation Conditions

Identifier

Literal

ArithmeticExpression

Identifier

Literal

ArithmeticExpression

IS

NOT GREATER THAN

NOT >

NOT LESS THAN

NOT <

NOT EQUAL TO

NOT =

GREATER THAN OR EQUAL TO

>=

LESS THAN OR EQUAL TO

<=

Page 4: Conditions.. IF Syntax.   Simple Conditions l Relation Conditions l Class Conditions l Sign Conditions   Complex Conditions   Condition Names

Class Conditions.Class Conditions.

Although COBOL data items are not ‘typed’ they Although COBOL data items are not ‘typed’ they do fall into some broad categories, or classes, do fall into some broad categories, or classes, such a numeric or alphanumeric, etc.such a numeric or alphanumeric, etc.

A Class Condition determines whether the value A Class Condition determines whether the value of data item is a member of one these classes.of data item is a member of one these classes.

Identifier IS [NOT]

NUMERIC

ALPHABETIC

ALPHABETIC - LOWER

ALPHABETIC - UPPER

UserDefinedClassName

Page 5: Conditions.. IF Syntax.   Simple Conditions l Relation Conditions l Class Conditions l Sign Conditions   Complex Conditions   Condition Names

Sign ConditionsSign Conditions

The sign condition determines whether or not the The sign condition determines whether or not the value of an arithmetic expression is less than, value of an arithmetic expression is less than, greater than or equal to zero.greater than or equal to zero.

Sign conditions are just another way of writing Sign conditions are just another way of writing some of the Relational conditions.some of the Relational conditions.

ArithExp IS [NOT]

POSITIVE

NEGATIVE

ZERO

Page 6: Conditions.. IF Syntax.   Simple Conditions l Relation Conditions l Class Conditions l Sign Conditions   Complex Conditions   Condition Names

Complex conditions.Complex conditions.

Programs often require conditions which are more Programs often require conditions which are more complex than single value testing or determining a complex than single value testing or determining a data class.data class.

Like all other programming languages COBOL allows Like all other programming languages COBOL allows simple conditions to be combined using simple conditions to be combined using OROR and and ANDAND to form composite conditions.to form composite conditions.

Like other conditions, a complex condition evaluates Like other conditions, a complex condition evaluates to true or false.to true or false.

A complex condition is an expression which is A complex condition is an expression which is evaluated from left to right unless the order of evaluated from left to right unless the order of evaluation is changed by the precedence rules or evaluation is changed by the precedence rules or bracketing.bracketing.

Condition AND

OR Condition

Page 7: Conditions.. IF Syntax.   Simple Conditions l Relation Conditions l Class Conditions l Sign Conditions   Complex Conditions   Condition Names

Just like arithmetic expressions, complex conditions Just like arithmetic expressions, complex conditions are evaluated using precedence rules and the order of are evaluated using precedence rules and the order of evaluation may be changed by bracketing.evaluation may be changed by bracketing.

ExamplesExamplesIF Row > 0 IF Row > 0 ANDAND Row < 26 THEN Row < 26 THEN

DISPLAY “On Screen”DISPLAY “On Screen”END-IFEND-IF

IF VarA > VarC IF VarA > VarC OROR VarC = VarD VarC = VarD OROR VarA VarA NOTNOT = VarF = VarF DISPLAY “Done”DISPLAY “Done”

END-IFEND-IF

( ) ( ) ( ) ( )

( ) ( ) ( )( ) ( ) ( )

Complex conditions have precedence rules too.Complex conditions have precedence rules too.

Precedence Rules.Precedence Rules.1.1. NOTNOT = **

2.2. ANDAND = * or /

3.3. OROR = + or -

Precedence Rules.Precedence Rules.1.1. NOTNOT = **

2.2. ANDAND = * or /

3.3. OROR = + or -

Page 8: Conditions.. IF Syntax.   Simple Conditions l Relation Conditions l Class Conditions l Sign Conditions   Complex Conditions   Condition Names

Implied Subjects.Implied Subjects.

When a data item is involved in a relation condition When a data item is involved in a relation condition with each of a number of other items it can be tedious with each of a number of other items it can be tedious to have to repeat the data item for each condition. For to have to repeat the data item for each condition. For example, example,

IF TotalAmt > 10000 AND TotalAmt < 50000 THENIF Grade = “A” OR Grade = “B+” OR GRADE = “B” THENIF VarA > VarB AND VarA > VarC AND VarA > VarD

DISPLAY “VarA is the Greatest”END-IF

In these situations COBOL provides an abbreviation In these situations COBOL provides an abbreviation mechanism called mechanism called implied subjectsimplied subjects. .

The statements above may be re-written using implied The statements above may be re-written using implied subjects as;subjects as;

IF TotalAmt > 10000 AND < 50000 THENIF Grade=“A” OR “B+” OR “B” THENIF VarA > VarB AND VarC AND VarD

DISPLAY “VarA is the Greatest”END-IF

Implied SubjectsImplied SubjectsTotalAmt Grade = VarA >

Implied SubjectsImplied SubjectsTotalAmt Grade = VarA >

Page 9: Conditions.. IF Syntax.   Simple Conditions l Relation Conditions l Class Conditions l Sign Conditions   Complex Conditions   Condition Names

Nested IFsNested IFs

IF ( VarA < 10 ) AND ( VarB NOT > VarC ) THENIF VarG = 14 THEN

DISPLAY “First”ELSE

DISPLAY “Second”END-IF

ELSEDISPLAY “Third”

END-IF

IF ( VarA < 10 ) AND ( VarB NOT > VarC ) THENIF VarG = 14 THEN

DISPLAY “First”ELSE

DISPLAY “Second”END-IF

ELSEDISPLAY “Third”

END-IF

VarAVarA VarBVarB VarCVarC VarGVarG DISPLAYDISPLAY

3 4 15 14 3 4 15 15 3 4 3 14 13 4 15 14

VarAVarA VarBVarB VarCVarC VarGVarG DISPLAYDISPLAY

3 4 15 14 3 4 15 15 3 4 3 14 13 4 15 14

T T T T T T FirstFirst T T F T T F SecondSecond T F T F ThirdThird F T F T ThirdThird

Page 10: Conditions.. IF Syntax.   Simple Conditions l Relation Conditions l Class Conditions l Sign Conditions   Complex Conditions   Condition Names

Condition Names.Condition Names.

Wherever aWherever a condition condition can occur, such as in an IF can occur, such as in an IF statement or an EVALUATE or a PERFORM..UNTIL, statement or an EVALUATE or a PERFORM..UNTIL, a a CONDITION NAMECONDITION NAME (Level 88) may be used. (Level 88) may be used.

A Condition Name is essentially a BOOLEAN A Condition Name is essentially a BOOLEAN variable which is either variable which is either TRUETRUE or or FALSEFALSE..

Example.Example.

IF StudentRecord = HIGH-VALUES THEN IF StudentRecord = HIGH-VALUES THEN ActionActionThe statement above may be replaced by the one below. The condition name EndOfStudentFile may be used instead of the condition StudentRecord = HIGH-VALUES.

IF EndOfStudentFile THEN IF EndOfStudentFile THEN ActionAction

IF VarA GREATER THAN VarB THEN ActionCondition is either TRUE or False

Page 11: Conditions.. IF Syntax.   Simple Conditions l Relation Conditions l Class Conditions l Sign Conditions   Complex Conditions   Condition Names

Defining Condition Names.Defining Condition Names.

Condition Names are defined in the DATA DIVISION using Condition Names are defined in the DATA DIVISION using the special level numberthe special level number 88 88..

They are always associated with a data item and are defined They are always associated with a data item and are defined immediately after the definition of the data item.immediately after the definition of the data item.

A condition name takes the value A condition name takes the value TRUE TRUE or or FALSE FALSE depending depending on the value in its associated data item.on the value in its associated data item.

A Condition Name may be associated withA Condition Name may be associated with ANYANY data item data item whether it is a group or an elementary item.whether it is a group or an elementary item.

The VALUE clause is used to The VALUE clause is used to identify identify the values which make the values which make the Condition Name TRUE.the Condition Name TRUE.

88 ConditionName VALUE

VALUES

Literal

LowValue THROUGH

THRU HighValue

Page 12: Conditions.. IF Syntax.   Simple Conditions l Relation Conditions l Class Conditions l Sign Conditions   Complex Conditions   Condition Names

01 CityCode PIC 9 VALUE 5.88 Dublin VALUE 1.88 Limerick VALUE 2.88 Cork VALUE 3.88 Galway VALUE 4.88 Sligo VALUE 5.88 Waterford VALUE 6.88 UniversityCity VALUE 1 THRU 4.

01 CityCode PIC 9 VALUE 5.88 Dublin VALUE 1.88 Limerick VALUE 2.88 Cork VALUE 3.88 Galway VALUE 4.88 Sligo VALUE 5.88 Waterford VALUE 6.88 UniversityCity VALUE 1 THRU 4.

IF Limerick DISPLAY "Hey, we're home."END-IFIF UniversityCity PERFORM CalcRentSurchargeEND-IF

IF Limerick DISPLAY "Hey, we're home."END-IFIF UniversityCity PERFORM CalcRentSurchargeEND-IF

Dublin FALSE Limerick FALSECork FALSEGalway FALSESligo TRUEWaterford FALSEUniversityCity FALSE

City CodeCity Code

55

Page 13: Conditions.. IF Syntax.   Simple Conditions l Relation Conditions l Class Conditions l Sign Conditions   Complex Conditions   Condition Names

01 CityCode PIC 9 VALUE 5.88 Dublin VALUE 1.88 Limerick VALUE 2.88 Cork VALUE 3.88 Galway VALUE 4.88 Sligo VALUE 5.88 Waterford VALUE 6.88 UniversityCity VALUE 1 THRU 4.

01 CityCode PIC 9 VALUE 5.88 Dublin VALUE 1.88 Limerick VALUE 2.88 Cork VALUE 3.88 Galway VALUE 4.88 Sligo VALUE 5.88 Waterford VALUE 6.88 UniversityCity VALUE 1 THRU 4.

IF Limerick DISPLAY "Hey, we're home."END-IFIF UniversityCity PERFORM CalcRentSurchargeEND-IF

IF Limerick DISPLAY "Hey, we're home."END-IFIF UniversityCity PERFORM CalcRentSurchargeEND-IF

Dublin FALSE Limerick TRUECork FALSEGalway FALSESligo FALSEWaterford FALSEUniversityCity TRUE

City CodeCity Code

22

Page 14: Conditions.. IF Syntax.   Simple Conditions l Relation Conditions l Class Conditions l Sign Conditions   Complex Conditions   Condition Names

01 CityCode PIC 9 VALUE 5.88 Dublin VALUE 1.88 Limerick VALUE 2.88 Cork VALUE 3.88 Galway VALUE 4.88 Sligo VALUE 5.88 Waterford VALUE 6.88 UniversityCity VALUE 1 THRU 4.

01 CityCode PIC 9 VALUE 5.88 Dublin VALUE 1.88 Limerick VALUE 2.88 Cork VALUE 3.88 Galway VALUE 4.88 Sligo VALUE 5.88 Waterford VALUE 6.88 UniversityCity VALUE 1 THRU 4.

IF Limerick DISPLAY "Hey, we're home."END-IFIF UniversityCity PERFORM CalcRentSurchargeEND-IF

IF Limerick DISPLAY "Hey, we're home."END-IFIF UniversityCity PERFORM CalcRentSurchargeEND-IF

Dublin FALSE Limerick FALSECork FALSEGalway FALSESligo FALSEWaterford TRUEUniversityCity FALSE

City CodeCity Code

66

Page 15: Conditions.. IF Syntax.   Simple Conditions l Relation Conditions l Class Conditions l Sign Conditions   Complex Conditions   Condition Names

01 InputChar PIC X.88 Vowel VALUE "A","E","I","O","U".88 Consonant VALUE "B" THRU "D", "F","G","H"

"J" THRU "N", "P" THRU "T""V" THRU "Z".

88 Digit VALUE "0" THRU "9".88 LowerCase VALUE "a" THRU "z".88 ValidChar VALUE "A" THRU "Z","0" THRU "9".

01 InputChar PIC X.88 Vowel VALUE "A","E","I","O","U".88 Consonant VALUE "B" THRU "D", "F","G","H"

"J" THRU "N", "P" THRU "T""V" THRU "Z".

88 Digit VALUE "0" THRU "9".88 LowerCase VALUE "a" THRU "z".88 ValidChar VALUE "A" THRU "Z","0" THRU "9".

IF ValidChar DISPLAY "Input OK."END-IFIF LowerCase

DISPLAY "Not Upper Case"END-IFIF Vowel Display "Vowel entered."END-IF

IF ValidChar DISPLAY "Input OK."END-IFIF LowerCase

DISPLAY "Not Upper Case"END-IFIF Vowel Display "Vowel entered."END-IF

Vowel TRUEConsonant FALSEDigit FALSELowerCase FALSEValidChar TRUE

Input CharInput Char

EE

Page 16: Conditions.. IF Syntax.   Simple Conditions l Relation Conditions l Class Conditions l Sign Conditions   Complex Conditions   Condition Names

01 InputChar PIC X.88 Vowel VALUE "A","E","I","O","U".88 Consonant VALUE "B" THRU "D", "F","G","H"

"J" THRU "N", "P" THRU "T""V" THRU "Z".

88 Digit VALUE "0" THRU "9".88 LowerCase VALUE "a" THRU "z".88 ValidChar VALUE "A" THRU "Z","0" THRU "9".

01 InputChar PIC X.88 Vowel VALUE "A","E","I","O","U".88 Consonant VALUE "B" THRU "D", "F","G","H"

"J" THRU "N", "P" THRU "T""V" THRU "Z".

88 Digit VALUE "0" THRU "9".88 LowerCase VALUE "a" THRU "z".88 ValidChar VALUE "A" THRU "Z","0" THRU "9".

IF ValidChar DISPLAY "Input OK."END-IFIF LowerCase

DISPLAY "Not Upper Case"END-IFIF Vowel Display "Vowel entered."END-IF

IF ValidChar DISPLAY "Input OK."END-IFIF LowerCase

DISPLAY "Not Upper Case"END-IFIF Vowel Display "Vowel entered."END-IF

Vowel FALSEConsonant FALSEDigit TRUELowerCase FALSEValidChar TRUE

Input CharInput Char

44

Page 17: Conditions.. IF Syntax.   Simple Conditions l Relation Conditions l Class Conditions l Sign Conditions   Complex Conditions   Condition Names

01 InputChar PIC X.88 Vowel VALUE "A","E","I","O","U".88 Consonant VALUE "B" THRU "D", "F","G","H"

"J" THRU "N", "P" THRU "T""V" THRU "Z".

88 Digit VALUE "0" THRU "9".88 LowerCase VALUE "a" THRU "z".88 ValidChar VALUE "A" THRU "Z","0" THRU "9".

01 InputChar PIC X.88 Vowel VALUE "A","E","I","O","U".88 Consonant VALUE "B" THRU "D", "F","G","H"

"J" THRU "N", "P" THRU "T""V" THRU "Z".

88 Digit VALUE "0" THRU "9".88 LowerCase VALUE "a" THRU "z".88 ValidChar VALUE "A" THRU "Z","0" THRU "9".

IF ValidChar DISPLAY "Input OK."END-IFIF LowerCase

DISPLAY "Not Upper Case"END-IFIF Vowel Display "Vowel entered."END-IF

IF ValidChar DISPLAY "Input OK."END-IFIF LowerCase

DISPLAY "Not Upper Case"END-IFIF Vowel Display "Vowel entered."END-IF

Vowel FALSEConsonant FALSEDigit FALSELowerCase TRUEValidChar FALSE

Input CharInput Char

gg

Page 18: Conditions.. IF Syntax.   Simple Conditions l Relation Conditions l Class Conditions l Sign Conditions   Complex Conditions   Condition Names

01 EndOfFileFlag PIC 9 VALUE 0.88 EndOfFile VALUE 1.

01 EndOfFileFlag PIC 9 VALUE 0.88 EndOfFile VALUE 1.

READ InFileAT END MOVE 1 TO EndOfFileFlag

END-READPERFORM UNTIL EndOfFile

StatementsREAD InFile

AT END MOVE 1 TO EndOfFileFlagEND-READ

END-PERFORM

READ InFileAT END MOVE 1 TO EndOfFileFlag

END-READPERFORM UNTIL EndOfFile

StatementsREAD InFile

AT END MOVE 1 TO EndOfFileFlagEND-READ

END-PERFORM

EndOfFile

EndOfFileFlagEndOfFileFlag

00

Page 19: Conditions.. IF Syntax.   Simple Conditions l Relation Conditions l Class Conditions l Sign Conditions   Complex Conditions   Condition Names

01 EndOfFileFlag PIC 9 VALUE 0.88 EndOfFile VALUE 1.

01 EndOfFileFlag PIC 9 VALUE 0.88 EndOfFile VALUE 1.

READ InFileAT END MOVE 1 TO EndOfFileFlag

END-READPERFORM UNTIL EndOfFile

StatementsREAD InFile

AT END MOVE 1 TO EndOfFileFlagAT END MOVE 1 TO EndOfFileFlagEND-READ

END-PERFORM

READ InFileAT END MOVE 1 TO EndOfFileFlag

END-READPERFORM UNTIL EndOfFile

StatementsREAD InFile

AT END MOVE 1 TO EndOfFileFlagAT END MOVE 1 TO EndOfFileFlagEND-READ

END-PERFORM

EndOfFileFlagEndOfFileFlag

11

EndOfFile

Page 20: Conditions.. IF Syntax.   Simple Conditions l Relation Conditions l Class Conditions l Sign Conditions   Complex Conditions   Condition Names

Using the SET verb.Using the SET verb.

01 FILLER PIC 9 VALUE 0.88 EndOfFile VALUE 1.88 NotEndOfFile VALUE 0.

01 FILLER PIC 9 VALUE 0.88 EndOfFile VALUE 1.88 NotEndOfFile VALUE 0.

READ InFileAT END SET EndOfFile TO TRUE

END-READPERFORM UNTIL EndOfFile

StatementsREAD InFile

AT END SET EndOfFile TO TRUEEND-READ

END-PERFORMSet NotEndOfFile TO TRUE.

READ InFileAT END SET EndOfFile TO TRUE

END-READPERFORM UNTIL EndOfFile

StatementsREAD InFile

AT END SET EndOfFile TO TRUEEND-READ

END-PERFORMSet NotEndOfFile TO TRUE.

EndOfFile 1NotEndOfFile 0

FILLERFILLER

00

Page 21: Conditions.. IF Syntax.   Simple Conditions l Relation Conditions l Class Conditions l Sign Conditions   Complex Conditions   Condition Names

Using the SET verb.Using the SET verb.

01 FILLER PIC 9 VALUE 0.88 EndOfFile VALUE 1.88 NotEndOfFile VALUE 0.

01 FILLER PIC 9 VALUE 0.88 EndOfFile VALUE 1.88 NotEndOfFile VALUE 0.

READ InFileAT END SET EndOfFile TO TRUE

END-READPERFORM UNTIL EndOfFile

StatementsREAD InFile

AT END SET EndOfFile TO TRUEAT END SET EndOfFile TO TRUEEND-READ

END-PERFORMSet NotEndOfFile TO TRUE.

READ InFileAT END SET EndOfFile TO TRUE

END-READPERFORM UNTIL EndOfFile

StatementsREAD InFile

AT END SET EndOfFile TO TRUEAT END SET EndOfFile TO TRUEEND-READ

END-PERFORMSet NotEndOfFile TO TRUE.

EndOfFile 1NotEndOfFile 0

FILLERFILLER

11

Page 22: Conditions.. IF Syntax.   Simple Conditions l Relation Conditions l Class Conditions l Sign Conditions   Complex Conditions   Condition Names

Using the SET verb.Using the SET verb.

01 FILLER PIC 9 VALUE 0.88 EndOfFile VALUE 1.88 NotEndOfFile VALUE 0.

01 FILLER PIC 9 VALUE 0.88 EndOfFile VALUE 1.88 NotEndOfFile VALUE 0.

READ InFileAT END SET EndOfFile TO TRUE

END-READPERFORM UNTIL EndOfFile

StatementsREAD InFile

AT END SET EndOfFile TO TRUEEND-READ

END-PERFORMSet NotEndOfFile TO TRUE.

READ InFileAT END SET EndOfFile TO TRUE

END-READPERFORM UNTIL EndOfFile

StatementsREAD InFile

AT END SET EndOfFile TO TRUEEND-READ

END-PERFORMSet NotEndOfFile TO TRUE.

EndOfFile 1NotEndOfFile 0

FILLERFILLER

00

Page 23: Conditions.. IF Syntax.   Simple Conditions l Relation Conditions l Class Conditions l Sign Conditions   Complex Conditions   Condition Names

PROCEDURE DIVISION.Begin. OPEN INPUT StudentFile READ StudentFile AT END SET EndOfFile TO TRUE END-READ PERFORM UNTIL EndOfFile DISPLAY StudentId SPACE StudentName SPACE CourseCode READ StudentFile AT END SET EndOfFile TO TRUE END-READ END-PERFORM CLOSE StudentFile STOP RUN.

PROCEDURE DIVISION.Begin. OPEN INPUT StudentFile READ StudentFile AT END SET EndOfFile TO TRUE END-READ PERFORM UNTIL EndOfFile DISPLAY StudentId SPACE StudentName SPACE CourseCode READ StudentFile AT END SET EndOfFile TO TRUE END-READ END-PERFORM CLOSE StudentFile STOP RUN.

FD StudentFile.01 StudentDetails. 88 EndOfFile VALUE HIGH-VALUES. 02 StudentId PIC 9(7). 02 StudentName. 03 Surname PIC X(8). 03 Initials PIC XX. 02 DateOfBirth. 03 YOBirth PIC 9(2). 03 MOBirth PIC 9(2). 03 DOBirth PIC 9(2). 02 CourseCode PIC X(4). 02 Grant PIC 9(4). 02 Gender PIC X.

FD StudentFile.01 StudentDetails. 88 EndOfFile VALUE HIGH-VALUES. 02 StudentId PIC 9(7). 02 StudentName. 03 Surname PIC X(8). 03 Initials PIC XX. 02 DateOfBirth. 03 YOBirth PIC 9(2). 03 MOBirth PIC 9(2). 03 DOBirth PIC 9(2). 02 CourseCode PIC X(4). 02 Grant PIC 9(4). 02 Gender PIC X.

Page 24: Conditions.. IF Syntax.   Simple Conditions l Relation Conditions l Class Conditions l Sign Conditions   Complex Conditions   Condition Names

The EvaluateThe Evaluate

EVALUATE

Identifier

Literal

CondExpression

ArithExpression

TRUE

FALSE

WHEN

ANY

Condition

TRUE

FALSE

NOT

Identifier

Literal

ArithExpression

THRU

THROUGH

Identifier

Literal

ArithExpression

StatementBlock

WHEN OTHER StatementBlock

END - EVALUATE

Page 25: Conditions.. IF Syntax.   Simple Conditions l Relation Conditions l Class Conditions l Sign Conditions   Complex Conditions   Condition Names

W I L L I A M S W I L L I A M S

EVALUATE TRUEEVALUATE TRUE PositionPositionWHEN L-Arrow 2 THRU 10WHEN L-Arrow 2 THRU 10 PERFORM MoveLeftPERFORM MoveLeftWHEN R-Arrow 1 THRU 9WHEN R-Arrow 1 THRU 9 PERFORM MoveRightPERFORM MoveRightWHEN L-Arrow 1WHEN L-Arrow 1 MOVE 10 TO PositionMOVE 10 TO PositionWHEN R-Arrow 10WHEN R-Arrow 10 MOVE 1 TO PositionMOVE 1 TO PositionWHEN DeleteKey 1WHEN DeleteKey 1 PERFORM CantDeletePERFORM CantDeleteWHEN Character ANYWHEN Character ANY PERFORM InsertCharPERFORM InsertCharWHEN OTHER PERFORM DisplayErrorMessageWHEN OTHER PERFORM DisplayErrorMessage

END-EVALUATEEND-EVALUATE

1 2 3 4 5 6 7 8 9 10

Page 26: Conditions.. IF Syntax.   Simple Conditions l Relation Conditions l Class Conditions l Sign Conditions   Complex Conditions   Condition Names

Decision Table Implementation.Decision Table Implementation.

EVALUATE Gender TRUE TRUEEVALUATE Gender TRUE TRUEWHENWHEN "M""M" Age<20Age<20 ANY ANY MOVE 5 TO BonusMOVE 5 TO BonusWHENWHEN "F""F" Age<20Age<20 ANY ANY MOVE 10 TO BonusMOVE 10 TO BonusWHENWHEN "M""M" Age>19 AND <41Age>19 AND <41 Service<10Service<10 MOVE 12 TO BonusMOVE 12 TO BonusWHENWHEN "F""F" Age>19 AND <41Age>19 AND <41 Service<10Service<10 MOVE 13 TO BonusMOVE 13 TO BonusWHENWHEN "M""M" Age>40Age>40 Service<10Service<10 MOVE 20 TO BonusMOVE 20 TO BonusWHENWHEN "F""F" Age>40Age>40 Service<10Service<10 MOVE 15 TO BonusMOVE 15 TO Bonus

: : :: :: :: : : : : :: :: :: ::

WHENWHEN "F""F" ANY ANY Service>20Service>20 MOVE 25 TO BonusMOVE 25 TO BonusEND-EVALUATEEND-EVALUATE

GenderGender M F M F M F M F Age Age <20 <20 20-40 20-40 40> 40> 20-40 20-40 etcServiceService Any Any <10 <10 <10 <10 10-20 10-20 etc% Bonus% Bonus 5 10 12 13 20 15 14 23