ผู้เขียน หัวข้อ: Hello world กับ Pascal Script  (อ่าน 8265 ครั้ง)

0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้

ออฟไลน์ manoi

  • Hero Member
  • *****
  • กระทู้: 8,669
  • Respect: +170
    • ดูรายละเอียด
    • HOSxP Community Center
Hello world กับ Pascal Script
« เมื่อ: กันยายน 04, 2006, 04:07:53 AM »
0
เพิ่งจะมีเวลาว่างครับ ก็เลยมานั่งเขียน ตัวอย่างการเขียนโปรแกรมด้วย Pascal Script ที่อยู่ใน HOSxP ดัดแปลงมาจากที่นี่ครับ http://www.delphibasics.co.uk/Article.asp?Name=FirstPgm

เป็น Script ที่มีปุ่มให้ผู้ใช้กดและจะแสดงข้อความ Hello World ครับ
ตัว Pascal Script Interpreter ที่มากับ HOSxP จะเรียกใช้ Procedure Main ใน Script ครับ ดังนั้นทุก Script จึงต้องมี Procedure Main ครับ

โค๊ด: Delphi
  1. // comment hello world script for hosxp
  2. // ชื่อ Unit จะตั้งเป็นอะไรก็ได้ ลงท้ายด้วยเครื่องหมาย เซมิโคล่อน
  3. Unit Script;  
  4.  
  5. // การประกาศตัวแปร ใช้คำว่า var  ตัวอย่างด้านล่างเป็นการประกาศตัวแปรชนิด TButton ,TLabel และ TForm โดยใช้ชื่อว่า Button1, Label1 และ Form1
  6. var
  7.   Button1 : TButton;
  8.   Label1 : TLabel;
  9.   Form1 : TForm;
  10.  
  11. Implementation
  12.  
  13. // กำหนด Procedure ชื่อ Button1Click สำหรับทำงานเมื่อมีการกดปุ่ม Button1
  14.  
  15. Procedure Button1Click(Sender : TObject);
  16. begin
  17.   Label1.caption := 'Hello World';
  18. end;
  19.  
  20. Procedure Main;
  21.  
  22. begin
  23.  
  24.   Form1 := TForm.create(nil);
  25.   Form1.Top := 100;
  26.   Form1.Left := 200;
  27.   Form1.Width := 400;
  28.   Form1.Height := 400;
  29.  
  30.   Button1 := TButton.create(Form1);
  31.   Button1.parent := Form1;
  32.   Button1.left:=100;
  33.   Button1.top:=50;
  34.   Button1.caption:='Click me';
  35.   Button1.OnClick := Button1Click;  // กำหนด Event เมื่อผู้ใช้เมาส์คลิกปุ่ม จะเรียกใช้งาน Procedure Button1Click ด้านบน
  36.  
  37.   Label1 := TLabel.create(Form1);
  38.   Label1.parent := Form1;
  39.   Label1.top:=55;
  40.   Label1.left:=200;
  41.   Label1.caption:='---';
  42.  
  43.   Form1.ShowModal;  // แสดง Form1 แบบ Modal Form
  44.  
  45.   Form1.Free;
  46. end;
  47. end.
  48.  
  49.  
  50.  
  51.  
« แก้ไขครั้งสุดท้าย: กันยายน 04, 2006, 04:20:41 AM โดย manoi »
HOSxP Project Manager / Cheif Developer / BMS MD

ออฟไลน์ naj

  • Hero Member
  • *****
  • กระทู้: 2,449
  • Respect: +8
    • ดูรายละเอียด
    • http://www.luangphopern-hospital.com
Re: Hello world กับ Pascal Script
« ตอบกลับ #1 เมื่อ: กันยายน 04, 2006, 04:54:02 AM »
0
 :Dขอบคุณครับ กำลังมองหาวิธีการเขียน pascal ที่ต้องการอยู่พอดีจะได้ลองไปปรับใช้ดูครับ ;D
Yindee And Tan

ออฟไลน์ ทานน้ำ

  • Full Member
  • ***
  • กระทู้: 204
  • ดวงพร ประกาศ(จอย) ผู้จัดการโครงการติดตั้งระบบฺBMS
  • Respect: +1
    • ดูรายละเอียด
Re: Hello world กับ Pascal Script
« ตอบกลับ #2 เมื่อ: พฤษภาคม 14, 2009, 14:13:26 PM »
0
มีตัวอย่าง ue ที่ link กันข้ามฟอร์มมั้ยคะ
ดวงพร  ประกาศ(จอย)
ผู้จัดการโครงการติดตั้งระบบและดูแลหลังการขาย
บริษัทบางกอกเมดิคอลซอฟต์แวร์จำกัด

doramon

  • บุคคลทั่วไป
Re: Hello world กับ Pascal Script
« ตอบกลับ #3 เมื่อ: พฤษภาคม 14, 2009, 16:23:02 PM »
0
ขอบคุณมากครับ

กำลังหาวิธีใช้ กับ UE อยู่ ครับ 

 ;D