Conditionals

In this section we will look at if/else statements and switch statements.

All this should be familiar to you if you have done any programming. You have your standard if/else, not/and/or operators, type comparisons, and switch statements. The only thing that might be a little weird are the pre-defined statements. What has essentially happened here is that the variable CHECK-VAL has these two conditions that depend on it (hence why PASS/FAIL are indented underneath CHECK-VAL) 88 is a special level number (like 01) for indicating that a statement is a custom conditional that depends on the 01 variable above it. You will also notice our STOP RUN is not indented here. This exits the whole program which is why you can indent or un-indent it from the procedure division.

Here are some examples using NOT/AND/OR as well as some other extras (imagine putting these into the procedure division above):

One last thing to notice: IF statements that do not have END-IF need a period to end them inside their last ‘sub statement.’


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *