JSP คืออะไร

Download Report

Transcript JSP คืออะไร

หลักการภาษาชุดคาสั่ง
COBOL Language
มหาวิทยาลัยเนชัน
่
http://www.nation.ac.th
http://www.thaiall.com/programming
อ.บุรน
ิ ทร ์
รุจจน
พันธุ ์ .
Page: 1
ประวัตภ
ิ าษา COBOL
ภาษาโคบอล (COBOL : Common
Business Oriented Language) เป็ น
ภาษาสาหรับใช้ในงานธุรกิจภาษาแรก
ของโลก พัฒนาในปี ค.ศ. 1962 โดย
คณะกรรมการโคดาซิล (The
Conference on Data Systems
Languages - CODASYL) มีจุดเดนคื
่ อ
สามารถใช้งานแฟ้มข้อมูลไดหลายแบบ
้
http://www.thaiall.com/cob
กาหนดโครงสรางข
สะดวก
มี
้ ลอมู
้ ขอมู
้ จากลได
้
http://www.thaiall.com/programming
Page: 2
ขอควรทราบเกี
ย
่ วกับภาษา
้
โดยพืน
้ ฐานแลว
้ COBOL
ประกอบดวย
4 Division และหลักแรก
้
ตองเริ
ม
่ ตนที
่ หลักที่
้
้ ่ 8 ส่วนคาสั่ งเริม
12 สาหรับตัวแปลภาษา COBOL
สมัยใหม่ สามารถยอมให้ละ 3
division แรกไวได
จึงใช้ตัวอยาง
้ ้
่
ขางล
างนี
้แสดงการเขียน COBOL
้
่
อยางสั
่ ้น
http://www.thaiall.com/programming
Page: 3
COBOL Division
identification division.
environment division.
data division.
procedure division.
http://www.thaiall.com/programming
Page: 4
Compiler Download
C:\>mkdir cobol
C:\>cd cobol
C:\cobol>pkunzip cobol3.zip
C:\cobol>cobol test,test,test,nul
C:\cobol>link test,test,nul,,nul
C:\cobol>test.exe
http://www.thaiall.com/downloadx/cobol3.zip
746 KB
http://www.thaiall.com/programming
Page: 5
Sample of Compiler File
C:\cobol> dir
01/21/1994
01/21/1994
01/21/1994
02/01/1992
02/01/1992
02/01/1992
02/01/1992
02/01/1992
02/01/1992
09/15/1995
02/01/1992
02/01/1992
02/01/1992
08:11
08:15
08:16
11:59
11:59
11:59
11:58
12:00
11:59
11:17
11:58
12:01
12:00
AM
AM
AM
AM
AM
AM
AM
PM
AM
AM
AM
PM
PM
http://www.thaiall.com/programming
70,420
35,924
37,924
2,048
304,896
27,008
97,936
223,232
47,104
74,420
152,064
119,150
206,592
ADIS.EXE
ADISINIT.EXE
ADISKEY.EXE
ANIMATOR.LBR
CHECK.LBR
COBCLI.LBR
COBOL.EXE
GENERATE.LBR
HELP.LBR
IXSIO.EXE
LCOBOL.LIB
LINK.EXE
UTILS.LBR
Page: 6
Compiling (1/2)
C:\cobol>cobol
Source file-name
Object file-name
Source listing
Object listing
[.CBL]: test
[X.OBJ]: test
[NUL.LST]: test
[NUL.GRP]: test
C:\cobol>link
Object Modules [.OBJ]: test
Run File [X.EXE]: test
List File [NUL.MAP]: test
Libraries [.LIB]:
Definitions File [NUL.DEF]: test
C:\cobol>test
5
http://www.thaiall.com/programming
Page: 7
Compiling (2/2)
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
http://www.thaiall.com/programming
Page: 8
สรางแฟ
้
้ ม short.cbl
DOS> edit short.cbl
procedure division.
display 5.
DOS> cobol short,short,short,nul
DOS> link short,short,nul,,nul
DOS> short.exe
http://www.thaiall.com/programming
Page: 9
สรางแฟ
้
้ ม test.cbl
DOS> notepad test.cbl
working-storage section.
77 x
pic 99.
procedure division.
move 0 to x.
perform cal-para until x >= 5.
stop run.
cal-para.
add 1 to x.
display x.
http://www.thaiall.com/programming
Page: 10
รับคาจากแป
่
้ นพิมพมา
์
working-storage section.
แสดงผล
01 a pic 999v99.
01 b pic zz9.99.
01 c pic 9999.
01 d pic z,zz9.
procedure division.
accept a.
move a to b.
display "1. result is " b.
accept c.
move c to d.
display "2. result is " d.
http://www.thaiall.com/programming
Page: 11
เลือกกระทาแบบ 2 แบบ
working-storage section.
01 s
pic 99.
procedure division.
accept s.
if s > 50 display "pass".
if s <= 50 display "fail".
stop run.
working-storage section.
01 s
pic 99.
procedure division.
accept s.
if s > 50
display "pass"
else
display "fail".
stop run.
----------------------------------------------------------------------------------
http://www.thaiall.com/programming
Page: 12
ทาซา้ เพือ
่ พิมพเลข
1
ถึ
ง
10
์
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.
http://www.thaiall.com/programming
Page: 13
แ
่
สดงการเขี
ย
น
ตัวอยางที
่
โปรแกรมทุกดิวช
ิ น
่ั
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).
http://www.thaiall.com/programming
Page: 14
Batch File of CBL.BAT
DOS>cbl test
DOS>type cbl.bat
@echo off
cls
if exist %1.obj del %1.obj >nul
if exist %1.exe del %1.exe >nul
echo Program is compiled. Please,wait for the compilation.
echo
cobol %1,%1,%1,nul
if not exist %1.obj goto end1
cls
echo Program is linked. Please,wait for the linking.
link %1,%1,nul,,nul
if not exist %1.exe goto end
if
exist %1.obj del %1.obj >nul
if
exist %1.lst del %1.lst >nul
cls
%1
goto end
:end1
type %1.lst
echo Error on your source.
:end
http://www.thaiall.com/programming
Page: 15