![]() | ภาษาโคบอล (COBOL Language) | ![]() |
|
ขอแนะนำ : COBUG.COM COBOL User Groups (COBUG) |
|
Division in COBOL
1. identification division. 2. environment division. 3. data division. 4. procedure division. Course outline 1. Course introduction 2. Principle of COBOL language 3. Language structuring 4. Command 5. Sequential processing 6. Decision processing 7. Repeating processing Midterm examination 8. Sequential file access 9. Index file access Final examination Case study : Sell system - sellpro.cbl - product.txt - sell.txt |
ปรับปรุงตาม หลักสูตรใหม่ |
|
| 2. สารบัญของหนังสือ | |
1.2 ข้อดี และข้อเสีย 1.3 ขั้นตอนการพัฒนาโปรแกรม 1.4 การทำงานของภาษาที่มีโครงสร้าง 1.5 โครงสร้างโปรแกรมภาษาโคบอล download : สรุปท้ายบท และแบบฝึกหัด
2.2 Identification division 2.3 Environment division 2.4 Data division 2.5 Procedure division 2.6 สัญลักษณ์ (Symbol) 2.7 คำ (Words) download : สรุปท้ายบท และแบบฝึกหัด
3.2 คำสั่งที่ใช้ในการคำนวณ (Arithmetic) 3.3 คำสั่งที่ใช้เคลื่อนย้าย (Data manipulation) 3.4 คำสั่งที่ใช้ควบคุมขั้นตอน (Procedure branching) 3.5 คำสั่งที่ใช้รับ และแสดงผล (Input/Output) download : สรุปท้ายบท และแบบฝึกหัด
4.2 การทำงานกับคำสั่งคำนวณ 4.3 การตกแต่งผลลัพธ์ก่อนนำไปแสดง 4.4 Redifines และ Renames 4.5 การกำหนดตัวแปรอาเรย์ และนำมาใช้ download : สรุปท้ายบท และแบบฝึกหัด |
5.2 ทดสอบความสัมพันธ์ (Relation conditions) 5.3 ทดสอบเป็นชุด (Nested conditions) 5.4 ทดสอบประเภทของข้อมูล (Class conditions) 5.5 ทดสอบเครื่องหมาย (Sign conditions) 5.6 ทดสอบชื่อเงื่อนไข (Condition-name conditions) 5.7 ทดสอบที่ซับซ้อน (Complex conditions) download : สรุปท้ายบท และแบบฝึกหัด
6.2 การทำซ้ำด้วยคำสั่ง Go to 6.3 การกำหนดจำนวนครั้งที่ทำซ้ำ 6.4 การทำซ้ำจนกระทั่งเงื่อนไขเป็นจริง 6.5 การทำซ้ำ โดยนำตัวเลขระบุรอบไปใช้งาน 6.6 การทำซ้ำ กับตัวแปรอาเรย์ (array) 6.7 การทำซ้ำ กับการเขียนโปรแกรมเมนู download : สรุปท้ายบท และแบบฝึกหัด
7.2 การอ่านข้อมูลมาประมวลผล และแสดงผล 7.3 การสร้างแฟ้มข้อมูล 7.4 การเพิ่มระเบียน 7.5 การปรับปรุงแฟ้ม 7.6 การจัดเรียงระเบียนใหม่ 7.7 การขอปรับปรุงข้อมูลจากแฟ้มข้อมูลย่อย download : สรุปท้ายบท และแบบฝึกหัด
8.2 การอ่านข้อมูลมาประมวล และแสดงผล 8.3 การค้นหาระเบียนที่ต้องการ 8.4 การเพิ่มระเบียน 8.5 การลบระเบียน 8.6 การแก้ไขระเบียน download : สรุปท้ายบท และแบบฝึกหัด |
| 3. วิธีแปล COBOL 4.5 |
|
FOR Cobol 4.5 C:\>c:\cobol\binr\new-vars.bat C:\>cd c:\cobol C:\cobol>cobol test,test,test,nul Microsoft (R) COBOL Optimizing Compiler Version 4.5 COBOL software by Micro Focus Copyright (C) Microsoft Corporation 1984,1991. All rights reserved. Copyright (C) Micro Focus Ltd. 1984,1991. All rights reserved. * Checking complete with no errors - starting code generation * Data = 000000613 Code = 000000276 Dictionary = 000001154 C:\cobol>link test,test,nul,,nul Microsoft (R) Segmented-Executable Linker Version 5.15 Copyright (C) Microsoft Corp 1984-1991. All rights reserved. C:\cobol>test 5 C:\cobol> |
| 4. Source code ของ batch file CBL.BAT | |
- สำหรับ COBOL compiler version 3.0 หรือ 4.5 - เมื่อเขียนโปรแกรม x.cbl เสร็จและต้องการแปล ให้พิมพ์ว่า C:\COBOL>CBL x |
| 5. ตัวอย่างโปรแกรม (Program sample) |
อย่างลืมว่า procedure เริ่มหลักที่ 8 และ display เริ่มหลักที่ 12 เพราะเป็นกฎเหล็กของภาษา Source code sample procedure division.
Source code sample working-storage section. 77 x pic 99. procedure division.
Source code sample working-storage section. 01 m pic 999. 01 a pic 999. 01 b pic 999. 01 c.
Source code sample working-storage section. 01 a pic 999v99 value 10. 01 b pic 999v99 value 5. 01 c pic 999v99. procedure division.
Source code sample working-storage section. 01 a pic 999v99. 01 b pic zz9.99. 01 c pic 9999. 01 d pic z,zz9. procedure division.
input screen sample Source code sample
identification division.
program-id. arraysample.
author. burin rujjanapan.
installation. yonok.
date-written. 20-09-97.
date-compiler. 20-09-97.
environment division.
configuration section.
source-computer. pc.
object-computer. pc.
data division.
working-storage section.
01 d occurs 10 times.
02 d-name pic x(5).
02 d-grade pic x.
01 cnt-a pic 99.
01 i pic 99.
01 j pic 99.
procedure division.
main-para.
display "Stop when d-grade(i) = 'q'".
move 0 to i.
perform get-para until d-grade(i) = "q".
move 0 to j.
display "" with blank screen.
display "Report when grade not equal 'f'".
perform report-para until i = j.
stop run.
get-para.
add 1 to i.
display "Number " i.
display "Get name : " with no advancing.
accept d-name(i).
display "Get grade: " with no advancing.
accept d-grade(i).
report-para.
add 1 to j.
if d-grade(j) not = "a"
display j, " : " with no advancing
display d-name(j), d-grade(j).
Source code sample
working-storage section.
77 sale pic 99999 value 0.
77 comm pic 9999v99 value 0.
procedure division.
display "Sale = " with no advancing.
accept sale.
if sale > 10000
compute comm = sale * 0.1
else if sale > 5000
compute comm = sale * 0.05
else if sale > 2000
compute comm = sale * 0.03.
display "Commission = " comm.
|
| 6. ตัวอย่างเกี่ยวกับการประมวลผลแฟ้มข้อมูล (File processing sample) |
โปรแกรมนี้ ได้คำแนะนำจาก อ.เยาวลักษณ์ งามแสนโรจน์ เกี่ยวกับการติดต่อแฟ้ม ขอบคุณไว้ ณ ที่นี้ Source code sample
identification division.
program-id. sample.
author. burin rujjanapan.
installation. lcct.
date-written. 20-09-97.
date-compiler. 20-09-97.
environment division.
configuration section.
source-computer. pc.
object-computer. pc.
input-output section.
file-control.
select infile assign to "x.cbl"
organization is line sequential.
data division.
file section.
fd infile.
01 inrec pic x(70).
working-storage section.
77 num pic 99 value 0.
77 flag-end pic x value "0".
procedure division.
initial-para.
open input infile.
read infile at end move "1" to flag-end.
perform main-para until flag-end = "1".
display "Total line = ",num.
stop run.
main-para.
add 1 to num.
display inrec.
read infile at end move "1" to flag-end.
|
| 7. ตัวอย่างคำสั่ง (Sample commands) |
|
| 8. สอบย่อย (Quiz) |
|
| 9. โครงงาน (Project) |
|
| 10. แนะนำเว็บ (Web guides) |
|