พื้นฐานปาสคาลพื้นฐาน rapidqเว็บภาษาไทยเว็บภาษาอังกฤษ

unit CRT ;

คำสั่งต่อไปนี้ หากต้องการจะใช้อย่าลืมเรียกใช้ ยูนิต crt นะครับ ( uses crt ; )
และบางอันใช้ได้กับ turbo pascal เท่านั้นนะครับ

procedure TEXTCOLOR
uses crt ;

begin
         clrscr ;
         textcolor(14) ;
         write( 'this color is..' );
         textcolor(7) ;
end.
this color is..
สีปกติของ text คือ 7 ครับ
ดังนั้นเราเมื่อเราใช้ textcolor(14) ; แล้ว
ควรกลับคืนสีเดิม ด้วย textcolor(7) ; ข้างหลังคำสั่ง write( ) ;

รหัสสี
0 
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
procedure TEXTBACKGROUND ;
uses crt ;

begin
         clrscr ;
         textbackground(7) ;
         write( 'this background is..' );
         textbackground(0) ;
end.
this background is..
สีปกติของ background คือ 0 ครับ
ดังนั้นเราเมื่อเราใช้ textbackground(7) ; แล้ว
ควรกลับคืนสีเดิม ด้วย textbackground(0) ; ข้างหลังคำสั่ง write( ) ;

procedure Delay( );
uses crt ;

begin
         clrscr ;
         writeln( 'please wait' );
         delay(2000);
         write( 'thank you' );
end.
please wait
รอประมาณ 2 วินาที ก็จะปรากฎตัวอักษร

thank you


screen 80 * 25
y\x12345678911234567892 123456789312345678941234567895 123456789612345678971234567898
1
2
3
4
5
6
7
8
9
10
12
13
14
15
16
17
18
19
20
20
21
22
23
24
25













                    10, 15
 



                     30, 5
      
procedure GOTOXY( ) ;
uses crt ;

begin
         clrscr ;
         gotoxy(10, 15);   write( 'ok1'  );
         gotoxy(30,   5);   write( 'ok2'  );
end.
ok1 จะอยู่ตำแหน่ง x10 , y15
ok2 จะอยู่ตำแหน่ง x30 , y5

x= แนวนอน
y= แนวตั้ง
เป็นโพรซีเจอร์ที่ช่วยให้เราสามารถกำหนดตำแหน่งของ string
ให้ไปยังตำแหน่งที่ต้องการ ตามแนวแกน x และ y
โดย text-screen ปกติมี x ขนาด 80 ช่อง y มีขนาด 25 ช่อง

ลองทำดูนะครับ
ส่วนตัวผม ชอบจำ x กับ y สลับกันอยู่บ่อยๆ
บางทีผมอาจจะบอกคุณผิดไปก็ได้ ต้องลองทดสอบดู

procedure SOUND( Hertz) ; DELAY(milli-second ) ; NOSOUND ;
uses crt ;

begin
         clrscr ;
         sound(500) ;   
         delay(250) ; 
         nosound ;		 
end.
ได้เสียง beep
ความถี่ 500 เฮิร์ซ ความยาว 0.25 วินาที
* * * สำคัญมากหากลืมโพรซีเจอร์ NoSound ; เสียงจะไม่หยุดนะ * * *

>> ยังมี ฟังค์ชั่น และ โพรซีเจอร์อีกหลายอันที่ใช้บ่อยๆ
>> วันนี้พอแค่นี้ก่อนครับผม..


best view with ie 5.0++, screen 600x800