Arithmetic Verb Template
ADD
MOVE ZERO TO NO. ADD 1 TO NO. 0 1
ADD MOVE TO SALARY. MOVE 2000 TO OVERTIME. ADD OVERTIME TO SALARY
ADD MOVE TO SALARY. MOVE 2000 TO OVERTIME. MOVE 1500 TO BONUS ADD OVERTIME BONUS TO SALARY
MOVE 7000 TO EXTRA MOVE TO SALARY. MOVE 2000 TO OVERTIME. MOVE 1500 TO BONUS ADD OVERTIME BONUS TO SALARY EXTRA ADD
ON SIZE ERROR
ADD – ON SIZE ERROR ADD OVERTIME TO SALARY ON SIZE ERROR DISPLAY “OVERFLOW” WRITE OUT-REC FROM OVERFLOW-LINE AFTER ADVANCING 1 END-ADD.
ADD - GIVING MOVE 45 TO SUM. ADD 20 TO SUM GIVING RESULT
ADD - GIVING ADD OVERTIME TO BONUS GIVING EXTRA ADD OVERTIME BONUS GIVING EXTRA EXTRABONUSOVERTIME (Edited characters)
ADD-GIVING ADD OVERTIME BONUS SALARY GIVING TOTAL INCOME SALARYBONUSOVERTIME (Edited PICTURE) INCOMETOTAL
ADD - ROUNDED 01 TOTAL PIC 9(5). 01 INCOME PIC 9(5)V99. ADD OVERTIME BONUS SALARY GIVING TOTAL ROUNDED INCOME SALARYBONUSOVERTIME (Edited characters) INCOMETOTAL
SUBTRACT
SUBTRACT WITHDRAW FROM TOTAL SUBTRACT 45 FROM TOTAL TOTAL WITHDRAWAL TOTAL TOTAL
SUBTRACT SUBTRACT PAY-M1 PAY-M2 FROM DEBT DEBTPAY-M DEBT 3000 PAY-M2
SUBTRACT
SUBTRACT PAY-M1 PAY-M2 FROM DEBT GIVING NEW-DEBT DEBTPAY-M NEW-DEBT 3000 PAY-M2 (Edited PICTURE)
SUBTRACT – ON SIZE ERROR SUBTRACT PAY-M1 PAY-M2 FROM DEBT GIVING NEW-DEBT ON SIZE ERROR PERFORM OVERFLOW-PARA END-SUBTRACT DEBTPAY-M NEW-DEBT 3000 PAY-M2 (Edited PICTURE)
MULTIPLY
MULTIPLY 0.07 BY PRICE PRICE 700 PRICE
MULTIPLY MULTIPLY GRADE BY CREDIT. 3.5 GRADE 3 CREDIT 10.5 CREDIT
MULTIPLY MULTIPLY QUANTITY BY PRICE-1 PRICE-2 20 QUANTITY 5.25 PRICE PRICE PRICE PRICE-2
MULTIPLY
MULTIPLY GRADE BY CREDIT GIVING RESULT. 3.5 GRADE 3 CREDIT 10.5 RESULT MULTIPLY GRADE BY CREDIT GIVING RESULT
MULTIPLY MULTIPLY QUANTITY BY PRICE-1 PRICE-2 ROUNDED 27 QUANTITY 7.39 PRICE PRICE PRICE PRICE-2
ROUNDED
DIVIDE
DIVIDE QUANTITY INTO TOTAL-PRICE. 20 QUANTITY 100 TOTAL-PRICE 5
DIVIDE DIVIDE 20 INTO TOTAL-PRICE. 100 TOTAL-PRICE 5 DIVIDE 20 INTO TOTAL-PRICE
DIVIDE DIVIDE QUANTITY INTO TPRICE-1 TPRICE-2. 5 QUANTITY 100 TPRICE TPRICE-2 20 TPRICE-1 40 TPRICE-2
DIVIDE
DIVIDE GIVING DIVIDE 20 INTO NUMBER GIVING RESULT DIVIDE NUMBER BY 20 GIVING RESULT 100 NUMBER 5 RESULT
DIVIDE GIVING ROUNDED DIVIDE NUMBER BY N GIVING RESULT-1 RESULT-2 ROUNDED. DIVIDE N INTO NUMBER GIVING RESULT-1 RESULT-2 ROUNDED. 5 NUMBER 103 N 20.6 RESULT-1 21 RESULT-2
DIVIDE REMAINDER
01 N PICTURE M PICTURE 9. DIVIDE 5 TO 23 GIVING N REMAINDER M. 4 N 3 M
DIVIDE REMAINDER 01 N PICTURE M PICTURE 9V9(3). DIVIDE 5.1 TO 23.5 GIVING N ROUNDED REMAINDER M. 5 N M 23.5/5.1 = 4.607
COMPUTE
COMPUTE RESULT = FIRST + SECOND * THIRD / FOURTH.
COMPUTE COMPUTE RESULT1 ROUNDED RESULT2 = FIRST + SECOND * THIRD / FOURTH
COMPUTE
• ใช้สำหรับการแสดงผลทางจอภาพ หรือ เครื่องพิมพ์ • ใช้เป็น operands ในการคำนวณไม่ได้ • ใช้เป็นตัวเก็บผลของการคำนวณได้ อาทิ อยู่ หลัง GIVING Edited Pictures
EDITED PICTURES
IF ELSE
CLASS CONDITION
NUMERIC : 0-9 และอาจมีเครื่องหมาย + - ALPHABETIC : อักษรพิมพ์ใหญ่ A-Z พิมพ์เล็ก a- z และที่ว่าง ALPHABETIC-LOWER : อักษรพิมพ์เล็ก a -z และ ที่ ว่าง ALPHABETIC-UPPER : อักษรตัวพิมพ์ใหญ่ A-Z และ ที่ว่าง Class-name : ตัวอักขระที่ได้ประกาศไว้ใน พารา กราฟ SPECIAL-NAME ของ ENVIRONMENT DIVISION
RELATION CONDITION
IF VAL-1 IS EQUAL TO 100 PERFORM EQUAL-100 END-IF IF VAL-1 = 100 PERFORM EQUAL-100 END-IF
RELATION CONDITION IF V-1 IS NOT GREATER THAN OR EQUAL V-2 PERFORM NOT-GREATER-EQUAL END-IF IF V-1 NOT >= V-2 PERFORM P-NOT-GREATER-EQUAL END-I
SIGN CONDITION
CONDITION-NAME CONDITION
NESTED IF
IF ValidChar DISPLAY "Input OK." ELSE IF LowerCase DISPLAY "NottUpper Case" ELSE IF Vowel Display "Vowel entered." END-IF
IF ValidChar DISPLAY "Input OK." ELSE IF LowerCase DISPLAY "NottUpper Case" ELSE IF Vowel Display "Vowel entered." END-IF
EVALUATE
01 BANKCODE PICTURE 9. …… EVALUATE BANKCODE WHEN 1 PERFORM DEPOSIT-PROCESS WHEN 2 PERFORM WITHDRAW-PROCESS WHEN 3 PERFORM LOAN-PROCESS WHEN OTHER PERFORM OTHER-PROCESS END-EVALUATE.
01 CTRY PICTURE X. ….. EVALUATE CTRY WHEN “A” THROUGH “D” PERFORM ABCD-CTRY WHEN “E” PERFORM E-CTRY WHEN OTHER PERFORM OTHER-CTRY END-EVALUATE
01 CUS PICTURE X(3). ….. EVALUATE CUS WHEN “NEW” PERFORM NEW-CUS WHEN “OLD” PERFORM OLD-CUS WHEN “VIP” PERFORM VIP-CUS END-EVALUATE
01 SPEC. 02 WEIGHT PIC HEIGHT PIC AGE PIC 99.
01 SCOREPICTURE 9(3). 88 GOOD VALUE 75 THRU PASS VALUE 50 THRU FAIL VALUE 0 THRU 49. ….. IF SCORE >= 75 AND <= 100 PERFORM GOOD-COUNTER ELSE IF SCORE >= 50 AND <=74 PERFORM PASS-COUNTER ELSE IF SCORE <= 49 PERFORM FAIL-COUNTER END-IF END-IF.
01 SCOREPICTURE 9(3). 88 GOOD VALUE 75 THRU PASS VALUE 50 THRU FAIL VALUE 0 THRU 49. ….. IF GOOD PERFORM GOOD-COUNTER ELSE IF PASS PERFORM PASS-COUNTER ELSE IF FAIL PERFORM FAIL-COUNTER END-IF
01 SCOREPICTURE 9(3). 88 GOOD VALUE 75 THRU PASS VALUE 50 THRU FAIL VALUE 0 THRU 49. ….. EVALUATE TRUE WHEN GOOD PERFORM GOOD-COUNTER WHEN PASS PERFORM PASS-COUNTER WHEN FAIL PERFORM FAIL-COUNTER END-EVALUATE