1 / 16

หลักการภาษาชุดคำสั่ง

หลักการภาษาชุดคำสั่ง. GW-Basic Language. มหาวิทยาลัยเนชั่น http:// www. nation. ac.th. อ.บุรินทร์ รุจจนพันธุ์ . ปรับปรุง 9 มิถุนายน 2556. ประวัติภาษา GW-BASIC.

Download Presentation

หลักการภาษาชุดคำสั่ง

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. หลักการภาษาชุดคำสั่ง GW-Basic Language มหาวิทยาลัยเนชั่น http://www.nation.ac.th อ.บุรินทร์ รุจจนพันธุ์ . ปรับปรุง 9 มิถุนายน 2556

  2. ประวัติภาษา GW-BASIC GW คำว่า GW ย่อมาจาก "Gee Whiz" เป็นภาษาในยุคแรก ๆ ที่ใช้ประกอบการสอนการเขียนโปรแกรมในคอมพิวเตอร์ และทำงานบน PC ได้ดีในระดับหนึ่ง มีการทำงานเป็น Interpreter มีการนำภาษานี้ใช้สอนในหนังสือ คอมพิวเตอร์เบื้องต้น และเทคนิคการเขียนโปรแกรม ที่เขียนโดย รศ.วัชราภรณ์ สุริยาภิวัฒน์ ที่มีการนำไปใช้สอนในสถาบันต่าง ๆ กันมาก เพราะมีการตีพิมพ์กว่า 20 ครั้ง ซึ่งสมัยผมเป็นนักศึกษา ก็เริ่มเรียนภาษานี้เป็นภาษาแรก ถูกพัฒนาขึ้นตั้งแต่ปีค.ศ. 1963 (พ.ศ.2506) ข้อมูลจาก http://www.thaiall.com/gwbasic/

  3. Compiler Download เป็นภาษาที่ง่ายใช้แฟ้ม GWBASIC.EXE เพียงแฟ้มเดียว ตัวแปลภาษา + http://www.oocities.org/KindlyRat/GWBASIC.html + http://www.oocities.org/rhinorc/gwbasic.html

  4. โปรแกรมแรกของฉัน (1/3) 10 cls 20 print 5 run ผลการพิมพ์ 2 บรรทัดนี้ในโปรแกรม - กำหนดเลขบรรทัด และใส่คำสั่ง - สั่งประมวลผลบรรทัดคำสั่งทั้งหมดที่มีในหน่วยความจำ - การประมวลผล สามารถกด F2 แทนการพิมพ์ run ได้ - ผลคือ 5 และคำว่า ok แสดงว่าสำเร็จเรียบร้อย

  5. โปรแกรมแรกของฉัน (2/3) จัดเก็บแฟ้มในห้องที่กำหนด และให้ Source Code เป็น ASCII save "c:\x.bas",a ออกจากโปรแกรม system DOS>type x.bas DOS>gwbasic x.bas

  6. โปรแกรมแรกของฉัน (3/3) DOS>gwbasic load "x.bas" list 10 cls 20 print 5 save "c:\x.bas",a

  7. ตัวอย่างข้อผิดพลาดจาก Interpreter 10 cls 20 print 5 30 a 40 print 10 run - ตัวอย่างนี้จะทำบรรทัดที่ 10 และ 20 - โปรแกรมหยุดทำงานบรรทัดที่ 30 ทันที - ถ้าเป็น Compiler จะตรวจสอบก่อนที่จะเริ่มประมวลผลบรรทัดแรก

  8. การรับค่า และแสดงผล 10 cls 20 dim a 30 input a 40 print a 50 dim b 60 input b 70 print b

  9. การรับค่า แล้วเลือกกระทำ 10 cls 20 a=0:b=0:c=0:d=0 30 input a 40 if a > 0 then input b 50 if b > 0 then input c 60 if c > 0 then d=a+b+c 70 print d

  10. คำสั่ง Go to ที่ถูกเลิกใช้ในภาษายุคเก่า 10 dim a 20 a = a + 1 30 print a 40 if a < 5 then go to 20 ตัวแปลภาษา http://www.oocities.org/KindlyRat/GWBASIC.html ข้อมูลจาก http://www.thaiall.com/gwbasic/

  11. คำสั่ง for สำหรับพิมพ์ 1 ถึง 5 10 FOR I = 1 TO 5 20 PRINT I 30 NEXT

  12. รับ 2 ค่า แสดงแสดงค่าที่สูงกว่า 10 a = 0 20 b = 0 30 m = 0 40 input a 50 input b 60 if a > b then m=a else m=b 70 print m

  13. รับ 5 ค่าลงอาร์เรย์แล้วแสดงค่าทั้งหมด 10 DIM AR(5) 20 FOR I = 1 TO 5 30 INPUT AR(I) 40 NEXT 50 FOR I = 1 TO 5 60 PRINT AR(I) 70 NEXT

  14. รับ 5 ค่าลงอาร์เรย์แล้วแสดงค่า Max 10 DIM AR(5) 20 MAX = 0 30 I = 0 40 FOR I = 1 TO 5 50 INPUT AR(I) 60 NEXT 70 FOR I = 1 TO 5 80 IF AR(I) > MAX THEN MAX = AR(I) 90 NEXT 100 PRINT MAX

  15. คำสั่งที่ควรรู้ cls Clear Screen i=0 กำหนดค่าให้กับตัวแปร print 5,5;5;5,5 , จะห่าง 1 tab ส่วน ; จะติดกัน goto 10 ไปทำงานบรรทัดที่ 10 input i รอรับตัวเลขจากแป้นพิมพ์ ($a คือ String) locate 5,40:print "x" ย้าย Cursor ไปตำแหน่งที่ต้องการ if i = 1 then cls else print "a" เลือก หรือตัดสินใจ for j = 1 to 5 .. ทำซ้ำด้วย for next save "a.bas",a จัดเก็บแบบ Ascii จึงเปิดด้วย Notepad ได้

  16. Game Sample หนทางอีกยาวไกล ก้าวต่อไปนะคนดี + http://www.thaiall.com/gwbasic/5starZ.bas + http://www.thaiall.com/gwbasic/flipper.bas + http://www.thaiall.com/gwbasic/roborat.bas + http://www.thaiall.com/gwbasic/search.bas . ข้อมูลจาก http://scottserver.net/basically/geewhiz.html (expired)

More Related