1 / 17

คำสั่ง READ รูปแบบ READ file-name RECORD [ INTO identifier] [AT END imperative-statement]

คำสั่ง READ รูปแบบ READ file-name RECORD [ INTO identifier] [AT END imperative-statement] ตัวอย่าง READ STUDENT-FILE AT END GO TO END-PROCESS. READ CUSTOMER-FILE AT END PERFORM END-JOB. คำสั่ง WRITE รูปแบบ WRITE record-name [ FROM identifier-1]

dcamilla
Download Presentation

คำสั่ง READ รูปแบบ READ file-name RECORD [ INTO identifier] [AT END imperative-statement]

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. คำสั่ง READ รูปแบบ READ file-name RECORD [INTO identifier] [AT END imperative-statement] ตัวอย่าง READ STUDENT-FILE AT END GO TO END-PROCESS. READ CUSTOMER-FILE AT END PERFORM END-JOB.

  2. คำสั่ง WRITE รูปแบบ WRITE record-name [FROM identifier-1] BEFORE ADVANCING AFTER identifier-2 LINE integer LINES PAGE ตัวอย่าง WRITE PRINT-LINE FROM HEAD-1 AFTER PAGE. [ { } } { { } ] [ ]

  3. คำสั่ง OPEN รูปแบบ OPENINPUT file-name-1 [, file-name-2]... OUTPUT file-name-3 [, file-name-4]... ตัวอย่าง OPEN INPUT STUDENT-FILE OUTPUT PRINT-FILE. { }

  4. คำสั่ง CLOSE รูปแบบ CLOSE file-name-1 [, file-name-2]... ตัวอย่าง CLOSE STUDENT-FILE PRINT-FILE.

  5. คำสั่ง MOVE รูปแบบ 1.MOVE identifier-1 TO identifier-2[, identifier-3]... literal 2. MOVECORRESPONDING CORR identifier-1 TO identifier-2 ตัวอย่าง MOVE SALARY TO SALARY-OUT. MOVE 0 TO A B C. MOVE “YES” TO EOF. { } } {

  6. คำสั่ง MOVE ตัวอย่างการใช้คำสั่ง MOVE กับตัวแปร 05 A-FIELD PIC X(9). 05 B-FIELD PIC X(5). ถ้าใช้คำสั่ง MOVE “SOME DATA” TO A-FIELD. MOVE “SOME DATA” TO B-FIELD. ผลลัพธ์ที่ได้ A-FIELD S O M E D A T A B-FIELD S O M E

  7. คำสั่ง MOVE ตัวอย่างการใช้คำสั่ง MOVE กับตัวแปร 05 X-FIELD PIC 9(6)V9(3). 05 Y-FIELD PIC 999V99. ถ้าใช้คำสั่ง MOVE 123.45 TO X-FIELD. MOVE 123.456 TO Y-FIELD. ผลลัพธ์ที่ได้ X-FIELD 0 0 0 1 2 3 4 5 0 Y-FIELD 1 2 3 4 5 ˆ ˆ

  8. คำสั่ง GO TO รูปแบบ 1.GO TO [procedure-name-1] 2. GO TO procedure-name-1 [, procedure-name-2]…, procedure-name-n DEPENDING ON identifier ตัวอย่าง GO TO MAIN-ROUTINE. GO TO PARA-1, PARA-2, PARA-3 DEPENDING ON SALES-CLASS.

  9. คำสั่ง IF รูปแบบ IF condition statement-1 NEXT SENTENCE ELSE statement-2 ELSENEXT SENTENCE ตัวอย่าง IF STUDENT-GPA > 1.99 NEXT SENTENCE ELSE PERFORM PRO-ROUTINE. { } { }

  10. คำสั่ง STOP รูปแบบ STOP RUN literal ตัวอย่าง STOP RUN. STOP “PRESS ENTER WHEN READY”. { }

  11. คำสั่ง COMPUTE รูปแบบ COMPUTE identifier-1 [ROUNDED] = arithmetic-expression [; ON SIZE ERROR imperative-statement] ตัวอย่าง COMPUTE A = 5.0 * B. COMPUTE X ROUNDED = B + C - D ON SIZE ERROR PERFORM ERROR-ROUTINE.

  12. คำสั่ง ADD รูปแบบ ADD field-name , field-name , field-name… literal literal literal GIVING field-name ตัวอย่าง ADD A B GIVING C. ADD S-FIELD, U-FIELD, 1.75 GIVING P. [ ] { } { }

  13. คำสั่ง SUBTRACT รูปแบบ SUBTRACT field-name , field-name ... literal literal FROM field-name GIVING field-name literal ตัวอย่าง SUBTRACT A FROM B GIVING C. (C = B - A) SUBTRACT X Y 1.5 FROM Z GIVING A. [ ] { } { }

  14. คำสั่ง MULTIPLY รูปแบบ MULTIPLY field-name BY field-name literal literal GIVING field-name ตัวอย่าง MULTIPLY A BY B GIVING C. (C = A * B) MULTIPLY 2.5 BY X GIVING Y. { } { }

  15. คำสั่ง DIVIDE รูปแบบ DIVIDE field-name INTO field-name literal BY literal GIVING field-name ตัวอย่าง DIVIDE A INTO B GIVING C. (C = B / A) DIVIDE B BY A GIVING C. { } { }

  16. คำสั่ง ADD, SUBTRACT, MULTIPLY, DIVIDE รูปแบบอื่น ๆ ADD field-name , field-name ... literal literal TO field-name ตัวอย่าง ADD 1 TO C. ADD A, B, 1.75 TO P. [ ] { }

  17. คำสั่ง ADD, SUBTRACT, MULTIPLY, DIVIDE ตัวอย่าง COMPUTE A = B + C * D / 2 - 5. is equivalent to the following sequence: MULTIPLY C BY D GIVING T-1. DIVIDE T-1 BY 2 GIVING T-2. ADD B, T-2 GIVING T-3. SUBTRACT 5 FROM T-3 GIVING A.

More Related