|  | ภาษาโคบอล (COBOL Language) |  | 
| 
 | COBOL User Groups (COBUG.COM) | 
| 
 | 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 8. Sequential file access 9. Index file access 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 | |
| เตรียมตัวแปลภาษา การใช้งานใน DOS ทดสอบกับ Index File | source code  | 
| FOR Cobol 4.5 C:\>c:\cobol\binr\new-vars.bat C:\>cd c:\cobol C:\cobol>cobol test,test,test,nul C:\cobol>link test,test,nul,,nul C:\cobol>test 5 C:\cobol> | |
| 4. รหัสต้นฉบับ batch file CBL.BAT | |
| 
 - สำหรับ COBOL compiler version 3.0 หรือ 4.5 - เมื่อเขียนโปรแกรม x.cbl เสร็จและต้องการแปล ให้พิมพ์ว่า C:\COBOL>CBL x | 
| 5. ตัวอย่างโปรแกรมอย่างง่าย | 
| ตัวอย่าง 5.1 : การแสดงผลอย่างง่าย 
 อย่างลืมว่า procedure เริ่มหลักที่ 8 และ display เริ่มหลักที่ 12 เพราะเป็นกฎเหล็กของภาษา รหัสต้นฉบับ procedure division. ตัวอย่าง 5.2 : ผ่าน หรือตก รหัสต้นฉบับ working-storage section. 01 s pic 99. procedure division. ตัวอย่าง 5.3 : พิมพ์ 1 ถึง 10 รหัสต้นฉบับ working-storage section. 77 x pic 99. procedure division. ตัวอย่าง 5.4 : ตารางสูตรคูณ รหัสต้นฉบับ working-storage section. 01 m pic 999. 01 a pic 999. 01 b pic 999. 01 c. ตัวอย่าง 5.5 : คำนวณอย่างง่าย รหัสต้นฉบับ working-storage section. 01 a pic 999v99 value 10. 01 b pic 999v99 value 5. 01 c pic 999v99. procedure division. ตัวอย่าง 5.6 : ย้ายเข้าตัวแปรแสดงผล รหัสต้นฉบับ working-storage section. 01 a pic 999v99. 01 b pic zz9.99. 01 c pic 9999. 01 d pic z,zz9. procedure division. ตัวอย่าง 5.7 : อาร์เรย์กับเกรด input screen 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).
ตัวอย่าง 5.8 : ค่านายหน้า รหัสต้นฉบับ
       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. ตัวอย่างเกี่ยวกับการประมวลผลแฟ้มข้อมูล | 
| ตัวอย่าง 6.1 : read and write to file รหัสต้นฉบับ
       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 disk.
              select outfile assign to disk.
       data division.
       file section.
       fd infile record contains 17 characters
              label record is standdard
              value of file-id "inf.txt".
       01 inrec pic x(17).
       fd outfile record contains 15 characters
              label record is standard
              value of file-id "outf.txt".
       01 outrec pic x(15).
       working-storage section.
       77 num      pic 99 value 0.
       77 flag-end pic x  value "0".
       procedure division.
       initial-para.
              open input infile
                   output outfile.
              read infile at end move "1" to flag-end.
              perform main-para until flag-end = "1".
              close outfile.
              display num.
              stop run.
       main-para.
              add 1 to num.
              write outrec from inrec before advancing 1 line.
              read infile at end move "1" to flag-end.
ตัวอย่าง 6.2 : read and write to file (shorter) รหัสต้นฉบับ
       environment division.
       input-output section.
       file-control.
              select infile  assign to disk.
              select outfile assign to disk.
       data division.
       file section.
       fd infile value of file-id "inf.txt".
       01 inrec.
          02 i-id     pic x(3).
          02 i-name   pic x(6).
          02 i-salary pic 999v99.
          02 i-sex    pic X.
          02 i-lf     pic XX.
       fd outfile value of file-id "outf.txt".
       01 outrec.
          02 o-id     pic x(3).
          02 o-name   pic x(6).
          02 o-salary pic 999v99.
          02 o-sex    pic X.
       working-storage section.
       77 num      pic 99 value 0.
       77 flag-end pic x  value "0".
       procedure division.
       initial-para.
              open input infile
                   output outfile.
              read infile at end move "1" to flag-end.
              perform main-para until flag-end = "1".
              close outfile.
              display "Total records : " num.
              stop run.
       main-para.
              add 1 to num.
              move inrec to outrec.
              if i-sex = "M"
                 write outrec from inrec before advancing 1 line
                 display o-id o-name.
	      read infile at end move "1" to flag-end.
ตัวอย่าง 6.3 : tax and total tax รหัสต้นฉบับ
       environment division.
       input-output section.
       file-control.
              select infile  assign to disk.
       data division.
       file section.
       fd infile value of file-id "inf.txt".
       01 inrec.
          02 i-id     pic x(3).
          02 i-name   pic x(6).
          02 i-salary pic 999v99.
          02 i-sex    pic X.
          02 i-lf     pic XX.
       working-storage section.
       77 num      pic 99 value 0.
       77 flag-end pic x  value "0".
       77 tax      pic 999v99.
       77 stax     pic 999v99 value 0.
       procedure division.
       initial-para.
              display "ID  NAME   SAL   S TAX".
              open input infile.
              read infile at end move "1" to flag-end.
              perform main-para until flag-end = "1".
              close infile.
              display "Total records : " num.
              display "Total tax: " stax.
              stop run.
       main-para.
              add 1 to num.
              multiply i-salary by 0.1 giving tax.
              add tax to stax.
              display i-id " " i-name " " i-salary " " i-sex " " tax.
              read infile at end move "1" to flag-end.
ตัวอย่าง 6.4 : read (line sequential) โปรแกรมนี้ ได้คำแนะนำจาก อ.เยาวลักษณ์ งามแสนโรจน์ เกี่ยวกับการติดต่อแฟ้ม ขอบคุณไว้ ณ ที่นี้ รหัสต้นฉบับ
       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. ตัวอย่างคำสั่ง | 
| 
 | 
| 8. สอบย่อย | 
| 
 | 
| 9. โครงงาน | 
| 
 | 
| 10. แนะนำเว็บ (Web guides) | 
| 
 |