✎...【C◕B◕L】™

posted on 04 Jul 2011 21:31 by liitz-37
                       ภาษาโคบอล
 
(COBOL : Common Business Oriented Language)
เป็นภาษาสำหรับใช้ในงานธุรกิจภาษาแรกของโลก พัฒนาในปี 1962
โดยคณะกรรมการโคดาซิล (The Conference on Data Systems
Languages - CODASYL) มีจุดเด่นคือ สามารถใช้งานแฟ้มข้อมูลได้
หลายแบบ กำหนดโครงสร้างข้อมูลได้สะดวก มีลักษณะการเขียนโปรแกรม
แบบเอกสารอธิบายโปรแกรม ช่วยให้ข้อมูลกับนักพัฒนารุ่นถัดไปได้ง่าย
และสะดวก นิยมใช้สำหรับการแก้ปัญหาทางด้านธุรกิจ เช่น การจัดเก็บ
เรียกใช้ และประมวลผลทางด้านบัญชี ตลอดจนทำงานด้านการ
ควบคุมสินค้าคงคลัง การรับและจ่ายเงิน เป็นต้น
คำสั่งของภาษา COBOL จะคล้ายกับภาษาอังกฤษทำให้สามารถ
อ่านและเขียนโปรแกรมได้ไม่ยากนัก ในยุคแรก ๆ ภาษา COBOL
จะได้รับความนิยมบนเครื่องระดับเมนเฟรม แต่ปัจจุบันนี้จะมีตัว
แปลภาษา COBOL ที่ใช้บนเครื่องไมโครคอมพิวเตอร์ด้วย
รวมทั้งมีภาษา COBOL ที่ได้รับการออกแบบตามแนวทางเชิงวัตถุ
(Object Oriented) เรียกว่า Visual COBOLซึ่งช่วยให้โปรแกรม
สามารถทำได้ง่ายขึ้น และสามารถนำโปรแกรมที่เขียนไว้มาใช้ใน
การพัฒนางานอื่น ๆ อีก
 

จุดเด่นของภาษา

 1. เหมาะกับงานทางธุรกิจ
 2. ภาษาคล้ายคลึงกับภาษาอังกฤษ
 3. มีความเป็นมาตรฐาน
 4. มีโครงสร้างภาษาที่ดี
 5. นำ มาใช้ได้กับเครื่องทุกระดับ
 

ข้อด้อยของภาษา

1. ใช้เวลาในการเขียนมาก
2. มีข้อจำ กัดด้านการคำ นวณ
3. มีภาษาอื่นที่เข้าใจได้ง่ายกว่าบน PC

ขั้นตอนการพัฒนาโปรแกรม ประกอบด้วย 5 ขั้นตอน

 1. การวิเคราะห์ปัญหา (Problem Analysis)
 2. การออกแบบโปรแกรม (Program design)
 3. การเขียนโปรแกรม (Programming)
 4. การทดสอบ และแก้ไขโปรแกรม (Testing & Debugging)
 5. การจัดทำ เอกสาร (Documentation)

การทำ งานตามหลักการโปรแกรมโครงสร้าง (Structured programming)

 1. การทำ งานแบบตามลำ ดับ (Sequence)
 2. การทำ งานแบบมีเงื่อนไข (Selection)
 3. การทำ งานแบบวนซํ้า (Loop)

โครงสร้างโปรแกรมภาษาโคบอล

 1. ไอเด็นทิฟิเคชั่นดิวิชัน (Identification division)
 2. เอ็นไวรอนเมนท์ดิวิชัน (Environment division)
 3. ดาต้าดิวิชัน (Data division)
 4. โพซิเดอร์ดิวิชัน (Procedure division)

การแบ่งพื้นที่(Area) ในภาษาโคบอล

 1. พื้นที่ A(Area A) เริ่มจากหลักที่ 8 ถึงหลักที่ 11
 2. พื้นที่ B(Area B) เริ่มจากหลักที่ 12 ถึงหลักที่ 72

ชื่อ มาตรฐาน และคำ ย่อ

 COBOL (COmmon Business Oriented Language)
 ANSI (American National Standard Institute)
CODASYL (Conference On Data System Language)
 
โปรแกรมภาษาโคบอลมี

4  Division

1. Identification division ทำ หน้าที่ คล้ายบทนำ
ของโปรแกรม ใช้ระบุชื่อโปรแกรม ชื่อผู้เขียน การติดตั้ง
วันที่เขียน วันที่แปล เป็นต้น
2. Environment division ทำหน้าที่ ประกาศชื่อเครื่องที่
เกี่ยวข้อง แฟ้มข้อมูลที่นำ มาใช้อุปกรณ์(Device) เป็นต้น
ในกรณีที่ไม่ใช้แฟ้มข้อมูล ผู้เขียนสามารถละ Division นี้ไว้ได้
3. Data division ทำหน้าที่ กำ หนดตัวแปร(Variable) และ
อธิบายลักษณะข้อมูล หรือเขตข้อมูลที่นำ ไปใช้ประมวลผลใน
procedure division ตัวแปรแต่ละตัวต้องกำ หนดรูปแบบ ขนาด
ระดับของตัวแปร และสามารถกำ หนดค่าเริ่มต้นของตัวแปรได้
4. Procedure division ทำหน้าที่ รวมคำ สั่งควบคุม และสั่งงาน
คอมพิวเตอร์ให้ทำ งานอย่างเป็นขั้นตอนเช่น การใช้คำ สั่งคำนวณ
อ่านแฟ้มข้อมูล เลือกเงื่อนไข หรือการวนซํ้า อยู่ในส่วนนี้ทั้งหมดมักเป็น
Division ที่ยาว และซับซ้อนที่สุดในการเขียนโปรแกรม

 

สัญลักษณ์ที่ใช้ในการกำ หนดรูปแบบของตัวแปร
X(Alphanumeric field) ค่าเป็น ตัวอักษร หรือตัวเลข
9(Numeric field) ค่าเป็น ตัวเลข
A(Alphabetic field) ค่าเป็นตัวอักษรหรือช่องว่าง
V(Assumed decimal point)เก็บจุดทศนิยมที่ตำ แหน่ง V เช่น 9V99 เป็นต้น
S(Operational sign) กำหนดให้เครื่องหมายบวก หรือลบมีผลกับตัวแปร
P(Decimal sealing position) ให้เลื่อนตำแหน่งออกไป
Z(Zero suppression character) เปลี่ยนเลข 0 ซึ่งอยู่หน้าจำ นวนเต็ม
ให้เป็น ช่องว่าง

 

ชนิดของข้อมูล(Type of data) แบ่งเป็น 2 ชนิดคือ
-ข้อมูลผันแปรได้ (Variabledata) ซึ่งเปลี่ยนแปลงค่าได้ และ
-ข้อมูลคงที่(Constant data or Literal data) ซึ่งกำ หนดไว้คงที่
เปลี่ยนแปลงค่าไม่ได้

กฎเกณฑ์การตั้งชื่อตัวแปร หรือคำ (Word name)

1. ความยาวต้องไม่เกิน 30 ตัวอักษร
2. ตัวแรกของชื่อต้องเป็นตัวอักษร ยกเว้นชื่อ Section หรือ Paragraph
ที่เขียนใน Proceduredivision สามารถเป็นตัวเลขล้วน ๆ ได้
3. ตัวอักษรที่นำ มาตั้งชื่อ ได้แก่ A-Z, 0-9 และเครื่องหมาย - (Hyphen)
4. เครื่องหมาย - (Hyphen) จะอยู่หน้าสุด หรือหลังสุดของชื่อไม่ได้
5. คำ แต่ละคำ เมื่อเขียนใกล้กันต้องห่างกันอย่างน้อย 1 ช่องว่าง ถึงแม้
จะใช้เครื่องหมายวรรคตอน(,;.) หลังเครื่องหมายวรรคตอน จะต้องมีช่องว่าง
อย่างน้อย 1 ช่องว่าง
6. ต้องไม่ซํ้ากับคำ สงวน(Reserved words) ที่มีอยู่

 

ตัวอย่าง  : ผ่าน หรือตก

:: รับค่าไปเปรียบเทียบ แล้วพิมพ์ pass หรือ fail

:: accept number and compare to display "pass" or "fail"

 

 

รหัสต้นฉบับ

working-storage section.

01 s   pic 99.

procedure division.

accept s.

if s > 50  display "pass".

if s <= 50 display "fail".

stop run.

 

 

 

ตัวอย่าง : พิมพ์ 1 ถึง 10

:: พิมพ์ 1 ถึง 10 โดยกำหนดค่าเริ่มต้นเป็น 0

:: print 1 to 10 by "perform .. until .." on screen

 

รหัสต้นฉบับ

working-storage section.

77 x   pic 99.

procedure division.

move 0 to x.

perform cal-para until x >= 10.

stop run.

cal-para.

add 1 to x.

display x.

Comment

smilebig smileopen-mounthed smileconfused smilesad smileangry smiletonguequestionembarrassedsurprised smilewinkdouble winkcry
smilebig smileopen-mounthed smileconfused smilesad smileangry smiletonguequestionembarrassedsurprised smilewinkdouble winkcry

Tweet

BO1QFo <a href="http://emeqyzcasjco.com/">emeqyzcasjco</a>, [url=http://ibhpvizitati.com/]ibhpvizitati[/url], [link=http://uixnprvraynz.com/]uixnprvraynz[/link], http://wejokivnzbgk.com/

#1 By DtBxvicyCtzt (85.25.95.90) on 2012-01-02 06:50

TvzcJj http://www.YPADZx4viosd5w2eNz85rtSpDsHQauOn.com

#2 By monOLcbLs (31.214.201.54) on 2012-02-25 03:54

YpiQts http://www.G1BFQuKyaBbxNAhMRORrhW8axcYq6IH3.com

#3 By ENreCURKPCJqNAde (213.141.245.62) on 2012-02-25 05:37

I want to make a withdrawal <a href=" http://wanktube4q.weebly.com ">wanktube </a> vgg <a href=" http://itsallgayja.weebly.com ">itsallgay </a> eujg <a href=" http://uselessjunk4s.weebly.com ">uselessjunk </a> 8-D

#4 By HrlMxqQQAHJNGBjAx (82.134.72.203) on 2012-02-26 05:45

I'd like a phonecard, please <a href=" http://xogogo2t.weebly.com ">xogogo </a> rpw <a href=" http://2adultflashgames6d.weebly.com ">2adultflashgames </a> =[[ <a href=" http://myhomeclipeg.weebly.com ">myhomeclip </a> krhq

#5 By DnBeIPltaYWSxD (210.212.150.84) on 2012-02-26 09:15

Not available at the moment <a href=" http://koostubegr.weebly.com ">koostube </a> 8896 <a href=" http://cucksharevn.weebly.com ">cuckshare </a> 9928 <a href=" http://fantastiax.weebly.com ">fantasti </a> tgity

#6 By sYLcKHCWlrgRfN (107.22.26.80) on 2012-02-26 12:13

I've got a very weak signal <a href=" http://xhamster36.weebly.com ">xhamster </a> 721296 <a href=" http://efuktmn.weebly.com ">efukt </a> 8053 <a href=" http://gayforital.weebly.com ">gayforit </a> 8]]]

#7 By gLekaKzwvLLZLPZcp (82.198.23.146) on 2012-02-26 14:33

this post is fantastic <a href=" http://lubetubea3.weebly.com ">lubetube </a> 8[[[ <a href=" http://zootube53.weebly.com ">zootube </a> 50945 <a href=" http://karupspcux.weebly.com ">karupspc </a> 710

#8 By bDhdDMcculCj (83.170.100.116) on 2012-02-26 16:55

I'm afraid that number's ex-directory <a href=" http://extremetubeqh.weebly.com ">extremetube </a> zwb <a href=" http://xnxxxq3.weebly.com ">xnxxx </a> lnlrg <a href=" http://empflixdp.weebly.com ">empflix </a> 824

#9 By WvKyCZvGfgXHw (95.0.187.236) on 2012-02-26 23:06

Have you got a telephone directory? <a href=" http://adultspaceyg.weebly.com ">adultspace </a> wejti <a href=" http://pronhub7x.weebly.com ">pronhub </a> crk <a href=" http://madmamasve.weebly.com ">madmamas </a> ecv

#10 By vrwvntGQMDgYO (81.177.166.190) on 2012-02-27 00:18

How would you like the money? <a href=" http://redtubeeb.weebly.com ">redtube </a> fpka <a href=" http://needbango8.weebly.com ">needbang </a> bufmm <a href=" http://gigantitsdk.weebly.com ">gigantits </a> 0653

#11 By MCjWOEbKQsnaIdVATQ (10.124.1.9, 203.177.115.3) on 2012-02-27 02:37

Sorry, you must have the wrong number <a href=" http://pichuntery4.weebly.com ">pichunter </a> >:((( <a href=" http://8tubel9.weebly.com ">8tube </a> %[[ <a href=" http://pronx6.weebly.com ">pron </a> knrflx

#12 By gjfloDcDUFIR (206.78.170.147) on 2012-02-27 09:22

What line of work are you in? <a href=" http://askjoleneq1.weebly.com ">askjolene </a> 82981 <a href=" http://dirtyrottenwhorer0.weebly.com ">dirtyrottenwhore </a> 8[[ <a href=" http://hairyboyz91.weebly.com ">hairyboyz </a> >:((

#13 By OwzLoKlzuDvLhnb (177.19.134.66) on 2012-02-27 10:28

How many more years do you have to go? <a href=" http://yazumsq.weebly.com ">yazum </a> =-DDD <a href=" http://stileprojectnm.weebly.com ">stileproject </a> fyz <a href=" http://gaywatch8r.weebly.com ">gaywatch </a> foss

#14 By SLgfxRIx (41.209.22.92) on 2012-02-27 19:38

I'll put her on <a href=" http://ro89xc.weebly.com ">ro89 </a> >:-]] <a href=" http://myarchives0t.weebly.com ">myarchives </a> xpy <a href=" http://tiavamd.weebly.com ">tiava </a> ivop

#15 By GUvbFlOxvQjSiHO (200.251.58.190) on 2012-02-27 23:22

A First Class stamp <a href=" http://bustnowv3.weebly.com ">bustnow </a> vvqvkd <a href=" http://spankingtubelf.weebly.com ">spankingtube </a> 9142 <a href=" http://imagefap75.weebly.com ">imagefap </a> 991443

#16 By jTTRCYtsKJKT (70.129.197.8) on 2012-02-28 01:44

I love this site <a href=" http://hentaimediane.weebly.com ">hentaimedia </a> wyy <a href=" http://ampland92.weebly.com ">ampland </a> olant <a href=" http://totallynsfwas.weebly.com ">totallynsfw </a> %]]

#17 By lyZAIIlGlXPa (70.129.197.8) on 2012-02-28 08:30

Incorrect PIN <a href=" http://bubblebuttc4.weebly.com ">bubblebutt </a> 905934 <a href=" http://myhomeclipssw.weebly.com ">myhomeclips </a> zwtz <a href=" http://boobtubef0.weebly.com ">boobtube </a> 8-]

#18 By ZVvVFThXRSNvVwbsjGb (75.147.206.177) on 2012-02-28 10:48

This is the job description <a href=" http://dailyninera0.weebly.com ">dailyniner </a> >:[[[ <a href=" http://8teenxxxjs.weebly.com ">8teenxxx </a> 01949 <a href=" http://definebabecb.weebly.com ">definebabe </a> ueyo

#19 By okrnWvIoUVti (180.179.100.119) on 2012-02-28 14:16

What sort of music do you like? <a href=" http://naughtyamericabo.weebly.com ">naughtyamerica </a> >:-DDD <a href=" http://yuvutu1r.weebly.com ">yuvutu </a> 2448 <a href=" http://beegvq.weebly.com ">beeg </a> =-]]]

#20 By wjnYFGiAsEIawBPp (85.92.159.84) on 2012-02-28 22:41

I'm doing a phd in chemistry <a href=" http://nakedfunnylx.weebly.com ">nakedfunny </a> 537 <a href=" http://heaven666ck.weebly.com ">heaven666 </a> =-)) <a href=" http://deviantclipswl.weebly.com ">deviantclips </a> :[[[

#21 By kEGzELzQRGuCS (64.31.57.13) on 2012-02-28 23:53

A pension scheme <a href=" http://cam4i4.weebly.com ">cam4 </a> exw <a href=" http://thumbzilla54.weebly.com ">thumbzilla </a> xftog <a href=" http://boysfood0x.weebly.com ">boysfood </a> efmjl

#22 By VwxyGNHdMB (46.73.66.221) on 2012-02-29 03:22

Will I get travelling expenses? <a href=" http://shooshtimee4.weebly.com ">shooshtime </a> jtlpn <a href=" http://fucduz.weebly.com ">fucd </a> :-( <a href=" http://sharmota5u.weebly.com ">sharmota </a> %(((

#23 By ZeHQCuHyeW (107.22.26.80) on 2012-02-29 04:31

I'd like to take the job <a href=" http://babeenvyos.weebly.com ">babeenvy </a> >:[ <a href=" http://holylolhk.weebly.com ">holylol </a> 81928 <a href=" http://kaktuz6x.weebly.com ">kaktuz </a> 9274

#24 By UIdnInrR (74.63.229.253) on 2012-02-29 05:40

What do you like doing in your spare time? <a href=" http://spermshackcp.weebly.com ">spermshack </a> nkior <a href=" http://badgirlsblogly.weebly.com ">badgirlsblog </a> 8[ <a href=" http://yobtuw.weebly.com ">yobt </a> %-[[[

#25 By AmDFjnJbgRvHQJJcYo (186.3.40.234) on 2012-02-29 09:06

One moment, please <a href=" http://moviesanduz.weebly.com ">moviesand </a> >:))) <a href=" http://watchhervideoyc.weebly.com ">watchhervideo </a> ynn <a href=" http://lubeyourtubet4.weebly.com ">lubeyourtube </a> nbsq

#26 By FAKMsOEWaj (94.232.173.222) on 2012-02-29 10:16

I want to report a <a href=" http://jizzhutbm.weebly.com ">jizzhut </a> =] <a href=" http://xxxstash4l.weebly.com ">xxxstash </a> 331390 <a href=" http://tube83y.weebly.com ">tube8 </a> 934

#27 By lhkcAxhMzxAsiuZGxG (187.1.8.14) on 2012-02-29 12:33

Not available at the moment <a href=" http://fooxy6n.weebly.com ">fooxy </a> :) <a href=" http://lizviciouskb.weebly.com ">lizvicious </a> frhf <a href=" http://gaytubes44.weebly.com ">gaytubes </a> 8-((

#28 By zQXLwWvqDSSsqvXf (213.42.240.154, 86.96.226.23) on 2012-02-29 17:10

Do you know each other? <a href=" http://youngleafsib.weebly.com ">youngleafs </a> 686805 <a href=" http://muchosuckofh.weebly.com ">muchosucko </a> >:-DDD <a href=" http://extremefusezf.weebly.com ">extremefuse </a> 07756

#29 By bJNCLHAIZlXTsLxT (66.208.119.195) on 2012-02-29 18:22

Do you know each other? <a href=" http://youngleafsib.weebly.com ">youngleafs </a> 686805 <a href=" http://muchosuckofh.weebly.com ">muchosucko </a> >:-DDD <a href=" http://extremefusezf.weebly.com ">extremefuse </a> 07756

#30 By bJNCLHAIZlXTsLxT (189.8.10.131) on 2012-02-29 18:22

Until August <a href=" http://madthumbsay.weebly.com ">madthumbs </a> uormde <a href=" http://xxxtubeef.weebly.com ">xxxtube </a> 075 <a href=" http://zootube365cz.weebly.com ">zootube365 </a> qufta

#31 By ScYTJPVdrqhnXc (186.3.41.25) on 2012-02-29 19:36

We'd like to invite you for an interview <a href=" http://sluttyredzk.weebly.com ">sluttyred </a> drt <a href=" http://xxxtubeshm.weebly.com ">xxxtubes </a> 831062 <a href=" http://monstercocktubeas.weebly.com ">monstercocktube </a> bintb

#33 By ndqDsQAgwNfBqYz (209.81.97.138) on 2012-03-01 03:29

I'm a member of a gym <a href=" http://redtubesmx.weebly.com ">redtubes </a> dgc <a href=" http://crazydumpere6.weebly.com ">crazydumper </a> 4785 <a href=" http://milfhunterxd.weebly.com ">milfhunter </a> hzfy

#34 By iiQfbXYfVW (188.134.89.203) on 2012-03-01 04:46

How do you spell that? <a href=" http://exgfpicsik.weebly.com ">exgfpics </a> 8] <a href=" http://amateurgalore1g.weebly.com ">amateurgalore </a> qzb <a href=" http://eroxiaak.weebly.com ">eroxia </a> :-P

#35 By fvOgmMPOTXy (121.52.71.23) on 2012-03-01 08:32

Can I take your number? <a href=" http://eskimotubev0.weebly.com ">eskimotube </a> >:-(( <a href=" http://teeniesxxxso.weebly.com ">teeniesxxx </a> 47774 <a href=" http://juggworldrv.weebly.com ">juggworld </a> dtmgsv

#36 By VnhZNIUcFyVMlATq (unknown, 184.106.220.249) on 2012-03-01 09:48

I'd like some euros <a href=" http://xtubesv3.weebly.com ">xtubes </a> >:(( <a href=" http://kinxxxlm.weebly.com ">kinxxx </a> 6766 <a href=" http://adultworkuq.weebly.com ">adultwork </a> dig

#37 By TWvcJnMqMTvGL (70.129.197.8) on 2012-03-01 11:04

I can't get a dialling tone <a href=" http://tubegalore6c.weebly.com ">tubegalore </a> 641 <a href=" http://voyeurwebx7.weebly.com ">voyeurweb </a> 288679 <a href=" http://kodiefiles0g.weebly.com ">kodiefiles </a> gfo

#38 By zfoXQroPQOjSqMGH (202.107.44.108) on 2012-03-01 17:30

vRGoOb <a href="http://hblfcixsfioq.com/">hblfcixsfioq</a>, [url=http://egzrmnlcuxzh.com/]egzrmnlcuxzh[/url], [link=http://uizxbnwfsbuu.com/]uizxbnwfsbuu[/link], http://qqqdyazfnciz.com/

#39 By OOprSQpMGNZJBOqlqBC (178.137.18.178) on 2012-03-04 23:35

Get a job <a href=" http://drtuber.posterous.com ">drtuber </a> bgnrzn <a href=" http://mofos.posterous.com ">mofos </a> =]]] <a href=" http://rawgonzo.posterous.com ">rawgonzo </a> 563504 <a href=" http://telaerotica.posterous.com ">telaerotica </a> 778

#40 By lAJIvpvqTodlD (62.92.115.100) on 2012-04-17 01:44

What sort of music do you like? <a href=" http://safadas.posterous.com ">safadas </a> rsuxu <a href=" http://evilangeltil.posterous.com ">evilangel </a> yom <a href=" http://wtuber.posterous.com ">wtuber </a> 0753 <a href=" http://hotgoo.posterous.com ">hotgoo </a> ayg

#41 By kSgDGdTv (190.66.17.53) on 2012-04-17 08:02

Where did you go to university? <a href=" http://naughtytube.posterous.com ">naughtytube </a> prrffz <a href=" http://carameltube.posterous.com ">carameltube </a> 9203 <a href=" http://feelmytube.posterous.com ">feelmytube </a> 68112 <a href=" http://forhertube.posterous.com ">forhertube </a> >:(((

#42 By ddXRmmZSdMbPZTf (57.90.36.29) on 2012-04-17 14:32

Where do you come from? <a href=" http://teencategories.posterous.com ">teencategories </a> pvpw <a href=" http://bravonude.posterous.com ">bravonude </a> %( <a href=" http://cumbrains.posterous.com ">cumbrains </a> >:]] <a href=" http://femandjoy.posterous.com ">femandjoy </a> eixtxv

#43 By ppLhwqgbRUNFj (72.204.66.5) on 2012-04-18 09:49

XQ0ga4 http://www.w5FW3qg9Z3X3nlvvBl2ynTXtMVqSAf2Z.com

#44 By qSHjuWdYIbCYKLNKf (103.7.57.18|190.90.36.8) on 2012-05-26 22:59