<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Computer Information System</title>
	<atom:link href="http://on006.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://on006.wordpress.com</link>
	<description>Rajamangala University of Technology ISAN - Khonkaen Campus</description>
	<lastBuildDate>Sat, 05 Jul 2008 20:52:40 +0000</lastBuildDate>
	<language>th</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='on006.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Computer Information System</title>
		<link>http://on006.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://on006.wordpress.com/osd.xml" title="Computer Information System" />
	<atom:link rel='hub' href='http://on006.wordpress.com/?pushpress=hub'/>
		<item>
		<title>เรื่องของตัวแปร Java</title>
		<link>http://on006.wordpress.com/2008/07/05/%e0%b9%80%e0%b8%a3%e0%b8%b7%e0%b9%88%e0%b8%ad%e0%b8%87%e0%b8%82%e0%b8%ad%e0%b8%87%e0%b8%95%e0%b8%b1%e0%b8%a7%e0%b9%81%e0%b8%9b%e0%b8%a3-java/</link>
		<comments>http://on006.wordpress.com/2008/07/05/%e0%b9%80%e0%b8%a3%e0%b8%b7%e0%b9%88%e0%b8%ad%e0%b8%87%e0%b8%82%e0%b8%ad%e0%b8%87%e0%b8%95%e0%b8%b1%e0%b8%a7%e0%b9%81%e0%b8%9b%e0%b8%a3-java/#comments</comments>
		<pubDate>Sat, 05 Jul 2008 20:52:40 +0000</pubDate>
		<dc:creator>on006</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://on006.wordpress.com/?p=9</guid>
		<description><![CDATA[การตั้งชื่อตัวแปร ชื่อของตัวแปรใน JavaScript สามารถขึ้นต้นด้วยตัวอักษรใหญ่ A-Z ตัวอักษรเล็ก (a-z) และ เครื่องหมาย _ ตามด้วย ตัวอักษร ตัวเลข หรือ เครื่องหมาย _ ก็ได้ ตัวอย่างชื่อตัวแปรที่ถูกต้อง orderNumber2 _456 SUM Image32 Amount_Click ข้อควรจำ ชื่อตัวแปรใน JavaScript จะเข้มงวดในการใช้ตัวอักษรใหญ่หรือเล็กด้วย(case sensitive) เช่น Sum SUM sum จะถือว่าไม่เป็นตัวแปรเดียวกันนะ ชนิดของตัวแแปร สิ่งที่ต่างจาก Java และ ภาษาบางภาษาคือ ผู้ใช้ภาษา JavaScript ไม่จำเป็นต้องกำหนดชนิดของตัวแปร ชึ่ง JavaScript จะสามารถรู้ได้เองว่า ในการนำตัวแปรไปใช้นั้น คุณต้องการให้มันเป็นตัวแปรชนิดไหน เช่นถ้าผมกำหนด ให้ตัวแปร Ahha มีค่าเป็น 1 ตัวแปร Ahha อาจจะให้ค่าเป็น True [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=on006.wordpress.com&amp;blog=4132251&amp;post=9&amp;subd=on006&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong><span style="color:#ff00ff;">การตั้งชื่อตัวแปร<br />
</span> <img src="http://www.pyayam.com/image/asd" border="0" alt="" width="20" height="1" /></strong>ชื่อของตัวแปรใน                JavaScript สามารถขึ้นต้นด้วยตัวอักษรใหญ่ A-Z ตัวอักษรเล็ก (a-z)                และ เครื่องหมาย _ ตามด้วย ตัวอักษร ตัวเลข หรือ เครื่องหมาย _ ก็ได้                ตัวอย่างชื่อตัวแปรที่ถูกต้อง<span id="more-9"></span></p>
<blockquote>
<p align="justify">orderNumber2<br />
_456<br />
SUM<br />
Image32<br />
Amount_Click</p></blockquote>
<p align="justify"><strong> ข้อควรจำ</strong> ชื่อตัวแปรใน JavaScript                จะเข้มงวดในการใช้ตัวอักษรใหญ่หรือเล็กด้วย(case sensitive) เช่น Sum                SUM sum จะถือว่าไม่เป็นตัวแปรเดียวกันนะ</p>
<p style="text-align:left;"><strong><span style="color:#ff00ff;">ชนิดของตัวแแปร<br />
</span> </strong> <strong><img src="http://www.pyayam.com/image/asd" border="0" alt="" width="20" height="1" /></strong>สิ่งที่ต่างจาก                Java และ ภาษาบางภาษาคือ ผู้ใช้ภาษา JavaScript ไม่จำเป็นต้องกำหนดชนิดของตัวแปร                ชึ่ง JavaScript จะสามารถรู้ได้เองว่า ในการนำตัวแปรไปใช้นั้น คุณต้องการให้มันเป็นตัวแปรชนิดไหน                เช่นถ้าผมกำหนด ให้ตัวแปร Ahha มีค่าเป็น 1 ตัวแปร Ahha อาจจะให้ค่าเป็น                True ได้ ถ้าคุณใช้มันไปในทางตรรก หรืออาจจะเป็น 1.0000 ก็ได้ แต่ความสามารถแบบนี้ก็เปรียบเสมือนดาบ                2 คม ในแง่หนึ่ง คุณสามารถใช้ตัวแปรได้อย่างอิสระเพราะไม่มีข้อจำกัดในด้านชนิดตัวแปร                และในอีกแง่หนึง คุณต้องจำได้ว่า ตัวแปรของคุณจะเป็นชนิดไหนในแต่ละขั้นตอนของการคำนวน</p>
<p align="justify">JavaScript สนับสนุนการใช้ตัวแปรเก็บค่าข้อมูล 4                ชนิดคือ</p>
<blockquote><p><strong>Integer</strong> คือ เลขจำนวนเต็ม<br />
<strong>Floating-point numbers</strong> คือ เลขจำนวนจริง<br />
<strong>Logic or boolean values</strong> คือ ตรรก(มีค่าแค่ถูกกับผิด)<br />
<strong>String</strong> คือ ข้อความ</p></blockquote>
<p align="justify">
<p style="text-align:left;"><strong><span style="color:#ff00ff;">ตัวแปรชนิดตัวเลข                : Integer and Floating-Point<br />
</span> </strong> <strong><img src="http://www.pyayam.com/image/asd" border="0" alt="" width="20" height="1" /></strong>ในการทำงานกับตัวเลข                JavaScript สามารถสนับสนุนได้ทั้ง Integer และ Float โดยทั้ง 2 ชนิด                สามารถ แปลงไปหากันได้โดยอัตโนมัติ<br />
ตัวแปร Integer ใน JavaScript จะอยู่ในรูปของเลขฐานได้ 3 ฐาน คือ 10                ,8 และ 16</p>
<p align="justify"><strong><img src="http://www.pyayam.com/image/asd" border="0" alt="" width="20" height="1" />ฐาน                10</strong> โดยปกติแล้วตัวเลขที่ใช้ใน JavaScript จะเป็นเลขฐาน 10                อยู่แล้ว<br />
<strong> <img src="http://www.pyayam.com/image/asd" border="0" alt="" width="20" height="1" />ฐาน                8</strong> จะมีเลขโดดอยู่แค่ 8 ตัว คือ 0-7 การเขียนเลขฐาน 8 จะใช้                0 นำหน้า<br />
<strong> <img src="http://www.pyayam.com/image/asd" border="0" alt="" width="20" height="1" />ฐาน                16</strong> จะมีเลขโดดอยู่ 16 ตัว คือ 0-9 และใช้ A-F แทน 10 &#8211; 15                การเขียนเลขฐาน 16 จะใช้ 0x นำหน้า</p>
<p align="justify">โปรแกรมตัวอย่างต่อไปนี้แสดงให้เห็นการใช้ เลขฐานครับ</p>
<table border="0" cellspacing="0" cellpadding="0" width="380" align="center">
<tbody>
<tr>
<td width="7%" valign="top"><span style="font-size:x-small;font-family:MS Sans Serif;"><a href="http://www.pyayam.com/" target="_blank"><img src="http://www.pyayam.com/java/image/notepad/notepad1.gif" border="0" alt="พยายาม" width="24" height="29" /></a></span></td>
<td width="72%" height="28" valign="middle"><span style="font-size:x-small;font-family:MS Sans Serif;"><strong> Pyayam.com :: พ ย า ย า ม ดอทคอม ::</strong></span></td>
<td width="21%" align="center">
<div><a href="http://www.pyayam.com/" target="_blank"><img src="http://www.pyayam.com/java/image/notepad/notepad2.gif" border="0" alt="พยายาม" width="77" height="29" /></a></div>
</td>
</tr>
<tr bgcolor="#ffccdd">
<td colspan="3"><span style="font-size:x-small;"><img src="http://www.pyayam.com/java/asd" alt="" width="7" height="1" /><img src="http://www.pyayam.com/java/asd" alt="" width="7" height="1" />File<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Edit<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Format<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />View<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Help</span></td>
</tr>
<tr>
<td colspan="3" height="28">
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td height="52">&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;Using                          JavaScript Integer&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;script language=&#8221;javascript&#8221;&gt;<br />
&lt;!&#8211;<br />
document.write(&#8220;0xab00 + 0xcd = &#8220;);<br />
document.write(0xab00 + 0xcd);<br />
document.write(&#8220;&lt;br&gt;&#8221;);<br />
document.write(&#8220;0xff &#8211; 0123 = &#8220;);<br />
document.write(0xff &#8211; 0123);<br />
document.write(&#8220;&lt;br&gt;&#8221;);<br />
document.write(&#8220;-0&#215;12 = &#8220;);<br />
document.write(-0&#215;12);<br />
// &#8211;&gt;<br />
&lt;/script&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<blockquote>
<p align="justify">ส่วน Float จะใช้กับ เลขทศนิยมหรือ เลขที่มีค่ามากๆและน้อยมากๆจนต้องเขียนในรูปของเลขยกกำลัง                  เช่น<br />
<span style="color:#0000ff;">-4.2132<br />
55.<br />
12e2 (อ่านว่า 12 คูณ 10 ยกกำลัง 2)<br />
1e-1 (อ่านว่า 1 คูณ 10 ยกกำลัง -1)<br />
.5<br />
-4e-4<br />
</span> ตัวอย่างโปรแกรมต่อไปนี้ เป็นการใช้ Floating-Point number                  ครับ</p>
<table border="0" cellspacing="0" cellpadding="0" width="380" align="center">
<tbody>
<tr>
<td width="7%" valign="top"><span style="font-size:x-small;font-family:MS Sans Serif;"><a href="http://www.pyayam.com/" target="_blank"><img src="http://www.pyayam.com/java/image/notepad/notepad1.gif" border="0" alt="พยายาม" width="24" height="29" /></a></span></td>
<td width="72%" height="28" valign="middle"><span style="font-size:x-small;font-family:MS Sans Serif;"><strong> Pyayam.com :: พ ย า ย า ม ดอทคอม ::</strong></span></td>
<td width="21%" align="center">
<div><a href="http://www.pyayam.com/" target="_blank"><img src="http://www.pyayam.com/java/image/notepad/notepad2.gif" border="0" alt="พยายาม" width="77" height="29" /></a></div>
</td>
</tr>
<tr bgcolor="#ffccdd">
<td colspan="3"><span style="font-size:x-small;"><img src="http://www.pyayam.com/java/asd" alt="" width="7" height="1" /><img src="http://www.pyayam.com/java/asd" alt="" width="7" height="1" />File<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Edit<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Format<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />View<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Help</span></td>
</tr>
<tr>
<td colspan="3" height="28">
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td height="52">
<p align="justify">&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;Using floating &#8211; point number&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;script language=&#8221;JavaScript&#8221;&gt;<br />
&lt;!&#8211;<br />
document.write(-5.465);<br />
document.write(&#8220;&lt;br&gt;&#8221;);<br />
document.write(57.);<br />
document.write(&#8220;&lt;br&gt;&#8221;);<br />
document.write(12e2);<br />
document.write(&#8220;&lt;br&gt;&#8221;);<br />
document.write(1e-2);<br />
document.write(&#8220;&lt;br&gt;&#8221;);<br />
document.write(7e1);<br />
document.write(&#8220;&lt;br&gt;&#8221;);<br />
document.write(-6e-2);<br />
document.write(&#8220;&lt;br&gt;&#8221;);<br />
document.write(.8);<br />
document.write(&#8220;&lt;br&gt;&#8221;);<br />
// &#8211;&gt;<br />
&lt;/script&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</blockquote>
<p style="text-align:left;">
<p align="justify"><strong><span style="color:#ff00ff;">ตัวแปรชนิดตรรก :                Logical Values<br />
</span> <img src="http://www.pyayam.com/image/asd" border="0" alt="" width="20" height="1" /></strong>เมื่อกี้ผมบอกว่า                JavaScript มีความสามารถในการเปลี่ยนชนิดตัวแปรโดยอัตโนมัติใช่ไหมครับ                งั้นลองทายดูว่าค่าตัวแปรชนิดที่เป็นตรรก คือ True และ False จะถูกแทนที่ด้วยค่าอะไร                ถ้ามัน ถูกเอามาใช้แบบเลขจำนวนเต็ม</p>
<blockquote>
<p align="justify">
<p align="justify">ตัวอย่างต่อไปนี้จะแสดงให้เห็นว่า Boolean สามารถเปลี่ยนเป็น                  Integer ได้ครับ</p>
<table border="0" cellspacing="0" cellpadding="0" width="380" align="center">
<tbody>
<tr>
<td width="7%" valign="top"><span style="font-family:MS Sans Serif;font-size:x-small;"><a href="http://www.pyayam.com/" target="_blank"><img src="http://www.pyayam.com/java/image/notepad/notepad1.gif" border="0" alt="พยายาม" width="24" height="29" /></a></span></td>
<td width="72%" height="28" valign="middle"><span style="font-family:MS Sans Serif;font-size:x-small;"><strong> Pyayam.com :: พ ย า ย า ม ดอทคอม ::</strong></span></td>
<td width="21%" align="center">
<div><a href="http://www.pyayam.com/" target="_blank"><img src="http://www.pyayam.com/java/image/notepad/notepad2.gif" border="0" alt="พยายาม" width="77" height="29" /></a></div>
</td>
</tr>
<tr bgcolor="#ffccdd">
<td colspan="3"><span style="font-size:x-small;"><img src="http://www.pyayam.com/java/asd" alt="" width="7" height="1" /><img src="http://www.pyayam.com/java/asd" alt="" width="7" height="1" />File<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Edit<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Format<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />View<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Help</span></td>
</tr>
<tr>
<td colspan="3" height="28">
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td height="52">
<p align="justify">&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;Conversation of logical values to numeric                              values&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;script language=&#8221;JavaScript&#8221;&gt;<br />
&lt;!&#8211;<br />
document.write(&#8220;true*5 + false *7 = &#8220;);<br />
document.write(true*5 + false *7);<br />
// &#8211;&gt;<br />
&lt;/script&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</blockquote>
<p align="center"><a href="http://www.pyayam.com/java/ex/21_1.html" target="_blank"><br />
</a></p>
<p align="justify">
<p align="right"><a href="history.back(1)"><br />
</a><a href="http://www.pyayam.com/java/21.php#"></a></p>
<hr />
<p align="justify">
<p align="justify"><strong><span style="color:#ff00ff;"><a name="2"></a>ตัวแปรชนิดข้อความ                : String<br />
</span> </strong> <strong><img src="http://www.pyayam.com/image/asd" border="0" alt="" width="20" height="1" /></strong>ตัวแปรหลักอีกตัวหนึ่งก็คือ                String หรือข้อความนั่นแหละครับ การใส่ค่าตัวแปร String ใน JavaScript                ให้ใช้เครื่องหมาย &#8221; หรือ &#8216; คร่อม ข้อความนั้นเช่น</p>
<p align="justify"><strong>&#8220;Hello String&#8221;<br />
&#8216;I am String&#8217;</strong></p>
<p><strong><img src="http://www.pyayam.com/image/asd" border="0" alt="" width="20" height="1" /></strong>ปัญหาก็จะเกิดตรงที่ว่าถ้าเราต้องการเขียนเครื่องหมาย                &#8216; หรือ &#8221; ใน String ล่ะ จะทำอย่างไร ก็มีทางแก้อยู่ 2 วิธีครับ                วิธีแรก คือ ถ้าต้องการแสดง &#8216; ก็เลี่ยงไปใช้ &#8221; เป็นตัวคร่อมชะ                เช่น</p>
<p><strong>&#8220;What&#8217;s New&#8221;</strong></p>
<p><strong><img src="http://www.pyayam.com/image/asd" border="0" alt="" width="20" height="1" /></strong>หรือถ้าต้องการแสดงทั้ง                2 ตัวพร้อมๆกันก็ต้องใช้ สัญลักษณ์พิเศษมาแทน (คล้ายๆกับใช้ &amp;lt;                มาแทน &lt; ใน HTML) เราจะใช้ \&#8221; มาแทน &#8221; และ \&#8217; มาแทน &#8216;                ครับ ดูจากตัวอย่างนะครับ</p>
<table border="0" cellspacing="0" cellpadding="0" width="380" align="center">
<tbody>
<tr>
<td width="7%" valign="top"><span style="font-family:MS Sans Serif;font-size:x-small;"><a href="http://www.pyayam.com/" target="_blank"><img src="http://www.pyayam.com/java/image/notepad/notepad1.gif" border="0" alt="พยายาม" width="24" height="29" /></a></span></td>
<td width="72%" height="28" valign="middle"><span style="font-family:MS Sans Serif;font-size:x-small;"><strong> Pyayam.com :: พ ย า ย า ม ดอทคอม ::</strong></span></td>
<td width="21%" align="center">
<div><a href="http://www.pyayam.com/" target="_blank"><img src="http://www.pyayam.com/java/image/notepad/notepad2.gif" border="0" alt="พยายาม" width="77" height="29" /></a></div>
</td>
</tr>
<tr bgcolor="#ffccdd">
<td colspan="3"><span style="font-size:x-small;"><img src="http://www.pyayam.com/java/asd" alt="" width="7" height="1" /><img src="http://www.pyayam.com/java/asd" alt="" width="7" height="1" />File<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Edit<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Format<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />View<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Help</span></td>
</tr>
<tr>
<td colspan="3" height="28">
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td height="52">&lt;html&gt;<br />
&lt;head&gt;&lt;title&gt;Using quote within string&lt;/title&gt;&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;script language=&#8221;JavaScript&#8221;&gt;<br />
&lt;!&#8211;<br />
document.write(&#8220;He said, \&#8221;That &#8216;s mine!\&#8221;&lt;br&gt;&#8221;);<br />
document.write(&#8216;She said, &#8220;No it\&#8217;s not.&#8221;&lt;br&gt;&#8217;);<br />
document.write(&#8216;That \&#8217;s all folks!&#8217;);<br />
//&#8211;&gt;<br />
&lt;/script&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<p align="center"><a href="http://www.pyayam.com/java/ex/21_2.html" target="_blank"><br />
</a></p>
<p>นอกจากนี้ JavaScript ยังมีสัญลักษณ์พิเศษที่สำคัญอีก 2 ตัว คือ</p>
<blockquote><p><strong>\n<img src="http://www.pyayam.com/image/asd" border="0" alt="" width="70" height="1" />ขึ้นบรรทัดใหม่<br />
\t<img src="http://www.pyayam.com/image/asd" border="0" alt="" width="70" height="1" />tab </strong></p></blockquote>
<p>ตัวอย่างการใช้ \n และ \t ครับ</p>
<table border="0" cellspacing="0" cellpadding="0" width="380" align="center">
<tbody>
<tr>
<td width="7%" valign="top"><span style="font-family:MS Sans Serif;font-size:x-small;"><a href="http://www.pyayam.com/" target="_blank"><img src="http://www.pyayam.com/java/image/notepad/notepad1.gif" border="0" alt="พยายาม" width="24" height="29" /></a></span></td>
<td width="72%" height="28" valign="middle"><span style="font-family:MS Sans Serif;font-size:x-small;"><strong> Pyayam.com :: พ ย า ย า ม ดอทคอม ::</strong></span></td>
<td width="21%" align="center">
<div><a href="http://www.pyayam.com/" target="_blank"><img src="http://www.pyayam.com/java/image/notepad/notepad2.gif" border="0" alt="พยายาม" width="77" height="29" /></a></div>
</td>
</tr>
<tr bgcolor="#ffccdd">
<td colspan="3"><span style="font-size:x-small;"><img src="http://www.pyayam.com/java/asd" alt="" width="7" height="1" /><img src="http://www.pyayam.com/java/asd" alt="" width="7" height="1" />File<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Edit<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Format<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />View<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Help</span></td>
</tr>
<tr>
<td colspan="3" height="28">
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td height="52">&lt;HTML&gt;<br />
&lt;HEAD&gt;<br />
&lt;TITLE&gt;Using special formatting characters&lt;/TITLE&gt;<br />
&lt;/HEAD&gt;<br />
&lt;BODY&gt;<br />
&lt;PRE&gt;<br />
&lt;SCRIPT LANGUAGE=&#8221;JavaScript&#8221;&gt;<br />
&lt;!&#8211;<br />
document.write(&#8220;This shows how the \ttab character                            works.\n&#8221;)<br />
document.write(&#8220;This shows how the \nnew line character                            works.\n&#8221;)<br />
// &#8211;&gt;<br />
&lt;/SCRIPT&gt;<br />
&lt;/PRE&gt;<br />
&lt;/BODY&gt;<br />
&lt;/HTML&gt;</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<p align="center"><a href="http://www.pyayam.com/java/ex/21_22.html" target="_blank"><br />
</a></p>
<p align="justify">
<p align="right"><a href="history.back(1)"><br />
</a><a href="http://www.pyayam.com/java/21.php#"></a></p>
<p align="right">
<hr />
<p align="justify">
<p align="justify"><strong><span style="color:#ff00ff;"><a name="3"></a>ตัวแปรว่างเปล่า                : ค่า null<br />
</span> </strong> <strong><img src="http://www.pyayam.com/image/asd" border="0" alt="" width="20" height="1" /></strong> ค่า null ก็คือค่าว่างเปล่า คือยังไม่มีค่าใดๆเก็บอยู่ในตัวแปร ดังนั้น                เมื่อเราประกาศตัวแปร ขึ้นมาตัวหนึงโดยไม่กำหนดค่าให้ ตัวแปรนั้นจะมีค่าเป็น                null ทันที และค่า null สามารถเปลี่ยนชนิดไป ตามสถานการณ์ได้เหมือนตัวแปรทั่่วๆไป</p>
<p align="justify">
<p align="justify"><strong><span style="color:#ff00ff;">ตารางผสมตัวแปรต่างชนิด<br />
</span></strong></p>
<table border="1" cellspacing="0">&lt;!&#8211;<br />
// Column headings for table<br />
document.write(&#8220;<TR>&#8220;);<br />
document.write(&#8220;<TD class="misc" bgcolor="cccccc">row + column</TD>&#8220;);<br />
document.write(&#8220;<TD class="misc" bgcolor="cccccc">string \&#8221;12.34/12.34.html\&#8221;</TD>&#8220;);<br />
document.write(&#8220;<TD class="misc" bgcolor="cccccc">integer 123</TD>&#8220;);<br />
document.write(&#8220;<TD class="misc" bgcolor="cccccc">float .123</TD>&#8220;);<br />
document.write(&#8220;<TD class="misc" bgcolor="cccccc">logical true</TD>&#8220;);<br />
document.write(&#8220;<TD class="misc" bgcolor="cccccc">logical false</TD>&#8220;);<br />
document.write(&#8220;<TD class="misc" bgcolor="cccccc">null</TD>&#8220;);<br />
document.write(&#8220;</TR>&#8220;);<br />
// First operand is a string<br />
document.write(&#8220;<TR>&#8220;);<br />
document.write(&#8220;<TD class="misc" bgcolor="cccccc">string \&#8221;test\&#8221;</TH>&#8220;);<br />
document.write(&#8220;<TD class="ptext">&#8220;);<br />
document.write(s1+s2);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(s1+i);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(s1+r);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(s1+lt);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(s1+lf);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(s1+n);<br />
document.write(&#8220;</TD>&#8220;);<br />
document.write(&#8220;</TR>&#8220;);<br />
// First operand is an integer<br />
document.write(&#8220;<TR>&#8220;);<br />
document.write(&#8220;<Td class="misc" bgcolor="cccccc">integer 123</Td>&#8220;);<br />
document.write(&#8220;<TD class="ptext">&#8220;);<br />
document.write(i+s2);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(i+i);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(i+r);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(i+lt);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(i+lf);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(i+n);<br />
document.write(&#8220;</TD>&#8220;);<br />
document.write(&#8220;</TR>&#8220;);<br />
// First operand is a float<br />
document.write(&#8220;<TR>&#8220;);<br />
document.write(&#8220;<Td class="misc" bgcolor="cccccc">float .123</Td>&#8220;);<br />
document.write(&#8220;<TD class="ptext">&#8220;);<br />
document.write(r+s2);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(r+i);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(r+r);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(r+lt);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(r+lf);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(r+n);<br />
document.write(&#8220;</TD>&#8220;);<br />
document.write(&#8220;</TR>&#8220;);<br />
// First operand is a logical true<br />
document.write(&#8220;<TR>&#8220;);<br />
document.write(&#8220;<Td class="misc" bgcolor="cccccc">logical true</Td>&#8220;);<br />
document.write(&#8220;<TD class="ptext">&#8220;);<br />
document.write(lt+s2);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(lt+i);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(lt+r);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(lt+lt);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(lt+lf);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(lt+n);<br />
document.write(&#8220;</TD>&#8220;);<br />
document.write(&#8220;</TR>&#8220;);<br />
// First operand is a logical false<br />
document.write(&#8220;<TR>&#8220;);<br />
document.write(&#8220;<Td class="misc" bgcolor="cccccc">logical false</Td>&#8220;);<br />
document.write(&#8220;<TD class="ptext">&#8220;);<br />
document.write(lf+s2);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(lf+i);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(lf+r);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(lf+lt);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(lf+lf);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(lf+n);<br />
document.write(&#8220;</TD>&#8220;);<br />
document.write(&#8220;</TR>&#8220;);<br />
// First operand is null<br />
document.write(&#8220;<TR>&#8220;);<br />
document.write(&#8220;<Td class="misc" bgcolor="cccccc">null</Td>&#8220;);<br />
document.write(&#8220;<TD class="ptext">&#8220;);<br />
document.write(n+s2);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(n+i);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(n+r);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(n+lt);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(n+lf);<br />
document.write(&#8220;</TD><TD class="ptext">&#8220;);<br />
document.write(n+n);<br />
document.write(&#8220;</TD>&#8220;);<br />
document.write(&#8220;</TR>&#8220;);<br />
// &#8211;&gt;</p>
<tbody>
<tr>
<td class="misc" bgcolor="#cccccc">row + column</td>
<td class="misc" bgcolor="#cccccc">string &#8220;12.34/12.34.html&#8221;</td>
<td class="misc" bgcolor="#cccccc">integer 123</td>
<td class="misc" bgcolor="#cccccc">float .123</td>
<td class="misc" bgcolor="#cccccc">logical true</td>
<td class="misc" bgcolor="#cccccc">logical false</td>
<td class="misc" bgcolor="#cccccc">null</td>
</tr>
<tr>
<td class="misc" bgcolor="#cccccc">string &#8220;test&#8221;</td>
<td class="ptext">test12.34</td>
<td class="ptext">test123</td>
<td class="ptext">test0.123</td>
<td class="ptext">testtrue</td>
<td class="ptext">testfalse</td>
<td class="ptext">testnull</td>
</tr>
<tr>
<td class="misc" bgcolor="#cccccc">integer 123</td>
<td class="ptext">12312.34</td>
<td class="ptext">246</td>
<td class="ptext">123.123</td>
<td class="ptext">124</td>
<td class="ptext">123</td>
<td class="ptext">123</td>
</tr>
<tr>
<td class="misc" bgcolor="#cccccc">float .123</td>
<td class="ptext">0.12312.34</td>
<td class="ptext">123.123</td>
<td class="ptext">0.246</td>
<td class="ptext">1.123</td>
<td class="ptext">0.123</td>
<td class="ptext">0.123</td>
</tr>
<tr>
<td class="misc" bgcolor="#cccccc">logical true</td>
<td class="ptext">true12.34</td>
<td class="ptext">124</td>
<td class="ptext">1.123</td>
<td class="ptext">2</td>
<td class="ptext">1</td>
<td class="ptext">1</td>
</tr>
<tr>
<td class="misc" bgcolor="#cccccc">logical false</td>
<td class="ptext">false12.34</td>
<td class="ptext">123</td>
<td class="ptext">0.123</td>
<td class="ptext">1</td>
<td class="ptext">0</td>
<td class="ptext">0</td>
</tr>
<tr>
<td class="misc" bgcolor="#cccccc">null</td>
<td class="ptext">null12.34</td>
<td class="ptext">123</td>
<td class="ptext">0.123</td>
<td class="ptext">1</td>
<td class="ptext">0</td>
<td class="ptext">0</td>
</tr>
</tbody>
</table>
<p align="right"><a href="history.back(1)"><br />
</a><a href="http://www.pyayam.com/java/22.php#"></a></p>
<hr />
<p align="justify">
<p align="justify"><strong><span style="color:#ff00ff;"><a name="2"></a>Function                เปลี่ยนชนิดตัวแปร<br />
</span> </strong> <strong><img src="http://www.pyayam.com/image/asd" border="0" alt="" width="20" height="1" /></strong> JavaScript สามารถแปรงร่างให้ตัวแปรได้จริงไหมครับ ถ้าผมมีเลขสักตัว                มันก็จะแปลี่ยนเป็น String ได้ ถ้าผมเอาไป + กับข้อความ แต่จากตารางที่แล้ว                จะเห็นได้ว่า string &#8220;12.34&#8243; ซึ่งเป็นข้อความที่เป็นตัวเลข                ไม่สามารถแปลงร่าง เป็นตัวเลขได้เลย เพราะ JavaScript เดาใจเราไม่ถูกว่าเมื่อไรที่จะให้มัน                เป็น Float หรือ String ดังนั้นเราจึงต้องมี Function ในการแปลงครับ<br />
JavaScript กำหนด Function มาให้ 3 ตัวครับคือ eval(),parseInt(),                และ parseFloat()</p>
<p align="justify"><strong><img src="http://www.pyayam.com/image/asd" border="0" alt="" width="20" height="1" />eval()</strong> จะใช้ในการเปลี่ยน String ที่อยู่ในรูปสมการให้เป็นค่าของผลลัพธ์เช่น                total=eval(&#8220;432.1*10&#8243;) Total ก็จะมีค่าเป็น 4321 และถ้าค่าของข้อความ                เป็นค่าที่ไม่สามารถแปลงได้ เช่น testxyz eval() จะไม่ส่งใดใดค่ากลับมา                ดังนั้น เราจะใช้ eval() ได้ก็ต้องแน่ใจว่าข้อมูลที่จะป้อนเข้า eval()                จะไม่มีข้อมูลที่ทำให้เกิด error อยู่</p>
<p align="justify"><strong><img src="http://www.pyayam.com/image/asd" border="0" alt="" width="20" height="1" />parseInt()</strong> จะใช้เปลี่ยนข้อความเป็นเลขจำนวนเต็มแต่ไม่เหมือนกับ eval() ตรงที่                มันจะแปลงให้เฉพาะตัวเลขที่อยู่หน้าสุดของข้อมูลและไม่สนใจข้อมูลแปลกปลอมเลย                เช่น parseInt(&#8220;123xyz&#8221;) ก็จะให้ค่าเป็น 123 และ parseInt(&#8220;xyz&#8221;)                ก็จะให้ค่าเป็น 0</p>
<p align="justify"><strong><img src="http://www.pyayam.com/image/asd" border="0" alt="" width="20" height="1" />parseFloat()</strong> คล้ายๆ parseInt() ครับ แต่จะใช้กีบเลขที่เป็น Float</p>
<p>เหมือนเดิมครับ ดูจากตัวอย่างเพื่อง่ายต่อการเข้าใจครับ</p>
<table border="0" cellspacing="0" cellpadding="0" width="380" align="center">
<tbody>
<tr>
<td width="7%" valign="top"><span style="font-family:MS Sans Serif;font-size:x-small;"><a href="http://www.pyayam.com/" target="_blank"><img src="http://www.pyayam.com/java/image/notepad/notepad1.gif" border="0" alt="พยายาม" width="24" height="29" /></a></span></td>
<td width="72%" height="28" valign="middle"><span style="font-family:MS Sans Serif;font-size:x-small;"><strong> Pyayam.com :: พ ย า ย า ม ดอทคอม ::</strong></span></td>
<td width="21%" align="center">
<div><a href="http://www.pyayam.com/" target="_blank"><img src="http://www.pyayam.com/java/image/notepad/notepad2.gif" border="0" alt="พยายาม" width="77" height="29" /></a></div>
</td>
</tr>
<tr bgcolor="#ffccdd">
<td colspan="3"><span style="font-size:x-small;"><img src="http://www.pyayam.com/java/asd" alt="" width="7" height="1" /><img src="http://www.pyayam.com/java/asd" alt="" width="7" height="1" />File<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Edit<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Format<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />View<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Help</span></td>
</tr>
<tr>
<td colspan="3" height="28">
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td height="52">&lt;HTML&gt;<br />
&lt;HEAD&gt;<br />
&lt;TITLE&gt;Using Explicit Conversion Functions&lt;/TITLE&gt;<br />
&lt;/HEAD&gt;<br />
&lt;BODY&gt;<br />
&lt;H1 ALIGN=&#8221;CENTER&#8221;&gt;Conversion Functions&lt;/H1&gt;<br />
&lt;SCRIPT LANGUAGE=&#8221;JavaScript&#8221;&gt;<br />
&lt;!&#8211;<br />
document.write(&#8216;eval(&#8220;12.34&#215;10&#8243;) = &#8216;);<br />
document.write(eval(&#8220;12.34&#215;10&#8243;););<br />
document.write(&#8220;&lt;BR&gt;&#8221;);<br />
document.write(&#8216;parseInt(&#8220;0&#215;10&#8243;) = &#8216;);<br />
document.write(parseInt(&#8220;0&#215;10&#8243;));<br />
document.write(&#8220;&lt;BR&gt;&#8221;);<br />
document.write(&#8216;parseFloat(&#8220;5.4321e6&#8243;) = &#8216;);<br />
document.write(parseFloat(&#8220;5.4321e6&#8243;));<br />
// &#8211;&gt;<br />
&lt;/SCRIPT&gt;<br />
&lt;/BODY&gt;<br />
&lt;/HTML&gt;</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<p align="right"><a href="history.back(1)"><br />
</a><a href="http://www.pyayam.com/java/22.php#"></a></p>
<p align="right">
<hr />
<p align="justify">
<p align="justify"><strong><span style="color:#ff00ff;"><a name="3"></a>การใช้                Array<br />
</span> </strong> <strong><img src="http://www.pyayam.com/image/asd" border="0" alt="" width="20" height="1" /></strong> Array ก็คือข้อมูลหลายๆตัวมาเรียงกันเป็นลำดับ ตัวอย่างเช่น ถ้าคุณต้องการแสดงชื่อของลูกค้า                5 คน บน WebPage ของคุณคุณก็ประกาศ Array ชื่อ employee ที่มีข้อมูล                5 ตัว ดังนี้</p>
<table border="0" cellspacing="0" cellpadding="0" width="380" align="center">
<tbody>
<tr>
<td width="7%" valign="top"><span style="font-family:MS Sans Serif;font-size:x-small;"><a href="http://www.pyayam.com/" target="_blank"><img src="http://www.pyayam.com/java/image/notepad/notepad1.gif" border="0" alt="พยายาม" width="24" height="29" /></a></span></td>
<td width="72%" height="28" valign="middle"><span style="font-family:MS Sans Serif;font-size:x-small;"><strong> Pyayam.com :: พ ย า ย า ม ดอทคอม ::</strong></span></td>
<td width="21%" align="center">
<div><a href="http://www.pyayam.com/" target="_blank"><img src="http://www.pyayam.com/java/image/notepad/notepad2.gif" border="0" alt="พยายาม" width="77" height="29" /></a></div>
</td>
</tr>
<tr bgcolor="#ffccdd">
<td colspan="3"><span style="font-size:x-small;"><img src="http://www.pyayam.com/java/asd" alt="" width="7" height="1" /><img src="http://www.pyayam.com/java/asd" alt="" width="7" height="1" />File<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Edit<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Format<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />View<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Help</span></td>
</tr>
<tr>
<td colspan="3" height="28">
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>employee = new Array(5);</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<p><strong><img src="http://www.pyayam.com/image/asd" border="0" alt="" width="20" height="1" /></strong>จากนั้นก็เอาชื่อลูกค้าไปเก็บไว้ใน                Array</p>
<table border="0" cellspacing="0" cellpadding="0" width="380" align="center">
<tbody>
<tr>
<td width="7%" valign="top"><span style="font-family:MS Sans Serif;font-size:x-small;"><a href="http://www.pyayam.com/" target="_blank"><img src="http://www.pyayam.com/java/image/notepad/notepad1.gif" border="0" alt="พยายาม" width="24" height="29" /></a></span></td>
<td width="72%" height="28" valign="middle"><span style="font-family:MS Sans Serif;font-size:x-small;"><strong> Pyayam.com :: พ ย า ย า ม ดอทคอม ::</strong></span></td>
<td width="21%" align="center">
<div><a href="http://www.pyayam.com/" target="_blank"><img src="http://www.pyayam.com/java/image/notepad/notepad2.gif" border="0" alt="พยายาม" width="77" height="29" /></a></div>
</td>
</tr>
<tr bgcolor="#ffccdd">
<td colspan="3"><span style="font-size:x-small;"><img src="http://www.pyayam.com/java/asd" alt="" width="7" height="1" /><img src="http://www.pyayam.com/java/asd" alt="" width="7" height="1" />File<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Edit<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Format<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />View<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Help</span></td>
</tr>
<tr>
<td colspan="3" height="28">
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>employee[0] = &#8220;Squall&#8221;;<br />
employee[1] = &#8220;Rinoa&#8221;;<br />
employee[2] = &#8220;Zell&#8221;;<br />
employee[3] = &#8220;Seifer&#8221;;<br />
employee[4] = &#8220;Irvine&#8221;;</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<p><strong><img src="http://www.pyayam.com/image/asd" border="0" alt="" width="20" height="1" /></strong>แล้วเวลาแสดงผลก็ใช้                document.write()</p>
<table border="0" cellspacing="0" cellpadding="0" width="380" align="center">
<tbody>
<tr>
<td width="7%" valign="top"><span style="font-family:MS Sans Serif;font-size:x-small;"><a href="http://www.pyayam.com/" target="_blank"><img src="http://www.pyayam.com/java/image/notepad/notepad1.gif" border="0" alt="พยายาม" width="24" height="29" /></a></span></td>
<td width="72%" height="28" valign="middle"><span style="font-family:MS Sans Serif;font-size:x-small;"><strong> Pyayam.com :: พ ย า ย า ม ดอทคอม ::</strong></span></td>
<td width="21%" align="center">
<div><a href="http://www.pyayam.com/" target="_blank"><img src="http://www.pyayam.com/java/image/notepad/notepad2.gif" border="0" alt="พยายาม" width="77" height="29" /></a></div>
</td>
</tr>
<tr bgcolor="#ffccdd">
<td colspan="3"><span style="font-size:x-small;"><img src="http://www.pyayam.com/java/asd" alt="" width="7" height="1" /><img src="http://www.pyayam.com/java/asd" alt="" width="7" height="1" />File<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Edit<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Format<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />View<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Help</span></td>
</tr>
<tr>
<td colspan="3" height="28">
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>document.write(employee[0]+&#8221;&lt;BR&gt;&#8221;);<br />
document.write(employee[1]+&#8221;&lt;BR&gt;&#8221;);<br />
document.write(employee[2]+&#8221;&lt;BR&gt;&#8221;);<br />
document.write(employee[3]+&#8221;&lt;BR&gt;&#8221;);<br />
document.write(employee[4]);</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<p><strong><img src="http://www.pyayam.com/image/asd" border="0" alt="" width="20" height="1" /></strong>เมื่อนำมาเขียนจะได้ตัวอย่างการใช้                Array ครับ</p>
<table border="0" cellspacing="0" cellpadding="0" width="380" align="center">
<tbody>
<tr>
<td width="7%" valign="top"><span style="font-family:MS Sans Serif;font-size:x-small;"><a href="http://www.pyayam.com/" target="_blank"><img src="http://www.pyayam.com/java/image/notepad/notepad1.gif" border="0" alt="พยายาม" width="24" height="29" /></a></span></td>
<td width="72%" height="28" valign="middle"><span style="font-family:MS Sans Serif;font-size:x-small;"><strong> Pyayam.com :: พ ย า ย า ม ดอทคอม ::</strong></span></td>
<td width="21%" align="center">
<div><a href="http://www.pyayam.com/" target="_blank"><img src="http://www.pyayam.com/java/image/notepad/notepad2.gif" border="0" alt="พยายาม" width="77" height="29" /></a></div>
</td>
</tr>
<tr bgcolor="#ffccdd">
<td colspan="3"><span style="font-size:x-small;"><img src="http://www.pyayam.com/java/asd" alt="" width="7" height="1" /><img src="http://www.pyayam.com/java/asd" alt="" width="7" height="1" />File<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Edit<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Format<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />View<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Help</span></td>
</tr>
<tr>
<td colspan="3" height="28">
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>&lt;HTML&gt;<br />
&lt;HEAD&gt;<br />
&lt;TITLE&gt;Using Arrays&lt;/TITLE&gt;<br />
&lt;/HEAD&gt;<br />
&lt;BODY&gt;<br />
&lt;H1 ALIGN=&#8221;CENTER&#8221;&gt;Using Arrays&lt;/H1&gt;<br />
&lt;SCRIPT LANGUAGE=&#8221;JavaScript&#8221;&gt;&lt;!&#8211;<br />
employee = new Array(5)<br />
employee[0] = &#8220;Squall&#8221;;<br />
employee[1] = &#8220;Rinoa&#8221;;<br />
employee[2] = &#8220;Zell&#8221;;<br />
employee[3] = &#8220;Seifer&#8221;;<br />
employee[4] = &#8220;Irvine&#8221;;<br />
document.write(employee[0]+&#8221;&lt;BR&gt;&#8221;);<br />
document.write(employee[1]+&#8221;&lt;BR&gt;&#8221;);<br />
document.write(employee[2]+&#8221;&lt;BR&gt;&#8221;);<br />
document.write(employee[3]+&#8221;&lt;BR&gt;&#8221;);<br />
document.write(employee[4]);<br />
// &#8211;&gt;<br />
&lt;/SCRIPT&gt;<br />
&lt;/BODY&gt;<br />
&lt;/HTML&gt;</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<p align="center"><a href="http://www.pyayam.com/java/ex/22_3.html" target="_blank"><br />
</a></p>
<p align="justify"><strong><img src="http://www.pyayam.com/image/asd" border="0" alt="" width="20" height="1" /></strong>จากตัวอย่างข้างต้น                Array ถูกกำหนด length ให้เป็น 5 แต่ ในการใช้จริงแล้ว เราไม่จำเป็นต้องกำหนด                length ก็ได้โดย length จะยืดหยุนได้ตามตัวแปรลำดับสุดท้าย เช่น ถ้าผมกำหนด</p>
<blockquote>
<p align="justify"><strong> employee = new array(); </strong></p>
</blockquote>
<p><strong><img src="http://www.pyayam.com/image/asd" border="0" alt="" width="20" height="1" /></strong>แล้วก็ใส่ค่า                employee[10] = &#8220;Sowrawoot&#8221;; employee.length ก็จะมีค่า                11 (นับ employee[0] เป็นตัวที่ 1) และจะเปลี่ยนค่าไปได้เรื่อยๆ ตามลำดับของข้อมูลตัวสุดท้าย</p>
<p align="justify"><strong><span style="color:#ff00ff;">การสร้าง Array แบบกำหนดค่าทันที</span></strong><br />
<strong><img src="http://www.pyayam.com/image/asd" border="0" alt="" width="20" height="1" /></strong> ทำได้โดยใส่ค่าลงไปใน Array ตั้งแต่ตอนประกาศเลย เราเรียก array ที่ประกาศด้วยวิธีนี้ว่า                dense array</p>
<table border="0" cellspacing="0" cellpadding="0" width="380" align="center">
<tbody>
<tr>
<td width="7%" valign="top"><span style="font-family:MS Sans Serif;font-size:x-small;"><a href="http://www.pyayam.com/" target="_blank"><img src="http://www.pyayam.com/java/image/notepad/notepad1.gif" border="0" alt="พยายาม" width="24" height="29" /></a></span></td>
<td width="72%" height="28" valign="middle"><span style="font-family:MS Sans Serif;font-size:x-small;"><strong> Pyayam.com :: พ ย า ย า ม ดอทคอม ::</strong></span></td>
<td width="21%" align="center">
<div><a href="http://www.pyayam.com/" target="_blank"><img src="http://www.pyayam.com/java/image/notepad/notepad2.gif" border="0" alt="พยายาม" width="77" height="29" /></a></div>
</td>
</tr>
<tr bgcolor="#ffccdd">
<td colspan="3"><span style="font-size:x-small;"><img src="http://www.pyayam.com/java/asd" alt="" width="7" height="1" /><img src="http://www.pyayam.com/java/asd" alt="" width="7" height="1" />File<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Edit<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Format<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />View<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Help</span></td>
</tr>
<tr>
<td colspan="3" height="28">
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>DayOfWeek = new Array(&#8216;Sun&#8217;,'Mon&#8217;,'Tue&#8217;,'Wed&#8217;,'Thu&#8217;,'Fri&#8217;,'Sat&#8217;)</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<p align="justify">
<p align="right"><a href="history.back(1)"><br />
</a><a href="http://www.pyayam.com/java/23.php#"></a></p>
<hr />
<p align="justify">
<p align="justify"><strong><span style="color:#ff00ff;"><a name="2"></a>การใช้                Array หลายมิติ<br />
</span> </strong> <strong><img src="http://www.pyayam.com/image/asd" border="0" alt="" width="20" height="1" /></strong> JavaScript ไม่ได้จำกัดว่าข้อมูลใน Array จะต้องเป็นชนิดเดียวกัน มันอาจเป็น                ข้อมูลต่างชนิดกันก็ได้ และจะเป็น Array ก็ได้ครับ ถ้ามี Array อยูใน                Array เป็น Array ซ้อน Array เช่น เวลาอ้างถึงก็จะทำแบบนี้ครับ</p>
<table border="0" cellspacing="0" cellpadding="0" width="380" align="center">
<tbody>
<tr>
<td width="7%" valign="top"><span style="font-family:MS Sans Serif;font-size:x-small;"><a href="http://www.pyayam.com/" target="_blank"><img src="http://www.pyayam.com/java/image/notepad/notepad1.gif" border="0" alt="พยายาม" width="24" height="29" /></a></span></td>
<td width="72%" height="28" valign="middle"><span style="font-family:MS Sans Serif;font-size:x-small;"><strong> Pyayam.com :: พ ย า ย า ม ดอทคอม ::</strong></span></td>
<td width="21%" align="center">
<div><a href="http://www.pyayam.com/" target="_blank"><img src="http://www.pyayam.com/java/image/notepad/notepad2.gif" border="0" alt="พยายาม" width="77" height="29" /></a></div>
</td>
</tr>
<tr bgcolor="#ffccdd">
<td colspan="3"><span style="font-size:x-small;"><img src="http://www.pyayam.com/java/asd" alt="" width="7" height="1" /><img src="http://www.pyayam.com/java/asd" alt="" width="7" height="1" />File<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Edit<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Format<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />View<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Help</span></td>
</tr>
<tr>
<td colspan="3" height="28">
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td height="52">&lt;span class=ptext&gt;<br />
ArrayName[ลำดับของ Array ตัวใหญ่][ลำดับของตัวใน]<br />
&lt;/span&gt;</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<p><strong><img src="http://www.pyayam.com/image/asd" border="0" alt="" width="20" height="1" /></strong>ตัวอย่างต่อไปจะแสดงให้เห็นถึงการใส่ข้อมูลต่างๆชนิดกันลงใน                Array และการใช้ Array ซ้อน Array ครับ</p>
<table border="0" cellspacing="0" cellpadding="0" width="380" align="center">
<tbody>
<tr>
<td width="7%" valign="top"><span style="font-family:MS Sans Serif;font-size:x-small;"><a href="http://www.pyayam.com/" target="_blank"><img src="http://www.pyayam.com/java/image/notepad/notepad1.gif" border="0" alt="พยายาม" width="24" height="29" /></a></span></td>
<td width="72%" height="28" valign="middle"><span style="font-family:MS Sans Serif;font-size:x-small;"><strong> Pyayam.com :: พ ย า ย า ม ดอทคอม ::</strong></span></td>
<td width="21%" align="center">
<div><a href="http://www.pyayam.com/" target="_blank"><img src="http://www.pyayam.com/java/image/notepad/notepad2.gif" border="0" alt="พยายาม" width="77" height="29" /></a></div>
</td>
</tr>
<tr bgcolor="#ffccdd">
<td colspan="3"><span style="font-size:x-small;"><img src="http://www.pyayam.com/java/asd" alt="" width="7" height="1" /><img src="http://www.pyayam.com/java/asd" alt="" width="7" height="1" />File<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Edit<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Format<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />View<img src="http://www.pyayam.com/java/asd" alt="" width="10" height="1" />Help</span></td>
</tr>
<tr>
<td colspan="3" height="28">
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td height="52">&lt;HTML&gt;<br />
&lt;HEAD&gt;<br />
&lt;TITLE&gt;Arrays within Arrays&lt;/TITLE&gt;<br />
&lt;/HEAD&gt;<br />
&lt;BODY&gt;<br />
&lt;H1 ALIGN=&#8221;CENTER&#8221;&gt;Arrays within Arrays&lt;/H1&gt;<br />
&lt;SCRIPT LANGUAGE=&#8221;JavaScript&#8221;&gt;&lt;!&#8211;<br />
junk = new Array(&#8220;s1&#8243;,&#8217;s2&#8242;,4,3.5,true,false,null,new                            Array(5,6,7));<br />
document.write(&#8220;junk[0] = &#8220;+junk[0]+&#8221;&lt;BR&gt;&#8221;);<br />
document.write(&#8220;junk[1] = &#8220;+junk[1]+&#8221;&lt;BR&gt;&#8221;);<br />
document.write(&#8220;junk[2] = &#8220;+junk[2]+&#8221;&lt;BR&gt;&#8221;);<br />
document.write(&#8220;junk[3] = &#8220;+junk[3]+&#8221;&lt;BR&gt;&#8221;);<br />
document.write(&#8220;junk[4] = &#8220;+junk[4]+&#8221;&lt;BR&gt;&#8221;);<br />
document.write(&#8220;junk[5] = &#8220;+junk[5]+&#8221;&lt;BR&gt;&#8221;);<br />
document.write(&#8220;junk[6] = &#8220;+junk[6]+&#8221;&lt;BR&gt;&#8221;);<br />
document.write(&#8220;junk[7][0] = &#8220;+junk[7][0]+&#8221;&lt;BR&gt;&#8221;);<br />
document.write(&#8220;junk[7][1] = &#8220;+junk[7][1]+&#8221;&lt;BR&gt;&#8221;);<br />
document.write(&#8220;junk[7][2] = &#8220;+junk[7][2]);<br />
// &#8211;&gt;<br />
&lt;/SCRIPT&gt;<br />
&lt;/BODY&gt;<br />
&lt;/HTML&gt;</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<p align="center"><a href="http://www.pyayam.com/java/ex/23_2.html" target="_blank"><br />
</a></p>
<p><strong><img src="http://www.pyayam.com/image/asd" border="0" alt="" width="20" height="1" /></strong>ก็จบไปอีก                1 บทนะครับ ตอนนี้ก็ยังเอา JavaScript ไปใช้อะไรไม่ได้หรอกครับ ตรงนี้เป็นแค่พื้นฐานของ                JavaScript เท่านั้นเอง แต่อย่าพึ่งใจร้อนครับ อีกไม่นานคุณ ก็จะใช้                JavaScript ท่องยุทธจักรได้แล้ว ถ้าติดขัดที่ไหนก็ e-mail มาได้นะครับ                ผมยินดีตอบคำถามครับ</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/on006.wordpress.com/9/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/on006.wordpress.com/9/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/on006.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/on006.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/on006.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/on006.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/on006.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/on006.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/on006.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/on006.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/on006.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/on006.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/on006.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/on006.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/on006.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/on006.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=on006.wordpress.com&amp;blog=4132251&amp;post=9&amp;subd=on006&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://on006.wordpress.com/2008/07/05/%e0%b9%80%e0%b8%a3%e0%b8%b7%e0%b9%88%e0%b8%ad%e0%b8%87%e0%b8%82%e0%b8%ad%e0%b8%87%e0%b8%95%e0%b8%b1%e0%b8%a7%e0%b9%81%e0%b8%9b%e0%b8%a3-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fd2f2b343fea71db0292fe37b17dcbd6?s=96&#38;d=identicon" medium="image">
			<media:title type="html">on006</media:title>
		</media:content>

		<media:content url="http://www.pyayam.com/image/asd" medium="image" />

		<media:content url="http://www.pyayam.com/image/asd" medium="image" />

		<media:content url="http://www.pyayam.com/image/asd" medium="image" />

		<media:content url="http://www.pyayam.com/image/asd" medium="image" />

		<media:content url="http://www.pyayam.com/image/asd" medium="image" />

		<media:content url="http://www.pyayam.com/image/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/image/notepad/notepad1.gif" medium="image">
			<media:title type="html">พยายาม</media:title>
		</media:content>

		<media:content url="http://www.pyayam.com/java/image/notepad/notepad2.gif" medium="image">
			<media:title type="html">พยายาม</media:title>
		</media:content>

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/image/notepad/notepad1.gif" medium="image">
			<media:title type="html">พยายาม</media:title>
		</media:content>

		<media:content url="http://www.pyayam.com/java/image/notepad/notepad2.gif" medium="image">
			<media:title type="html">พยายาม</media:title>
		</media:content>

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/image/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/image/notepad/notepad1.gif" medium="image">
			<media:title type="html">พยายาม</media:title>
		</media:content>

		<media:content url="http://www.pyayam.com/java/image/notepad/notepad2.gif" medium="image">
			<media:title type="html">พยายาม</media:title>
		</media:content>

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/image/asd" medium="image" />

		<media:content url="http://www.pyayam.com/image/asd" medium="image" />

		<media:content url="http://www.pyayam.com/image/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/image/notepad/notepad1.gif" medium="image">
			<media:title type="html">พยายาม</media:title>
		</media:content>

		<media:content url="http://www.pyayam.com/java/image/notepad/notepad2.gif" medium="image">
			<media:title type="html">พยายาม</media:title>
		</media:content>

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/image/asd" medium="image" />

		<media:content url="http://www.pyayam.com/image/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/image/notepad/notepad1.gif" medium="image">
			<media:title type="html">พยายาม</media:title>
		</media:content>

		<media:content url="http://www.pyayam.com/java/image/notepad/notepad2.gif" medium="image">
			<media:title type="html">พยายาม</media:title>
		</media:content>

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/image/asd" medium="image" />

		<media:content url="http://www.pyayam.com/image/asd" medium="image" />

		<media:content url="http://www.pyayam.com/image/asd" medium="image" />

		<media:content url="http://www.pyayam.com/image/asd" medium="image" />

		<media:content url="http://www.pyayam.com/image/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/image/notepad/notepad1.gif" medium="image">
			<media:title type="html">พยายาม</media:title>
		</media:content>

		<media:content url="http://www.pyayam.com/java/image/notepad/notepad2.gif" medium="image">
			<media:title type="html">พยายาม</media:title>
		</media:content>

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/image/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/image/notepad/notepad1.gif" medium="image">
			<media:title type="html">พยายาม</media:title>
		</media:content>

		<media:content url="http://www.pyayam.com/java/image/notepad/notepad2.gif" medium="image">
			<media:title type="html">พยายาม</media:title>
		</media:content>

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/image/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/image/notepad/notepad1.gif" medium="image">
			<media:title type="html">พยายาม</media:title>
		</media:content>

		<media:content url="http://www.pyayam.com/java/image/notepad/notepad2.gif" medium="image">
			<media:title type="html">พยายาม</media:title>
		</media:content>

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/image/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/image/notepad/notepad1.gif" medium="image">
			<media:title type="html">พยายาม</media:title>
		</media:content>

		<media:content url="http://www.pyayam.com/java/image/notepad/notepad2.gif" medium="image">
			<media:title type="html">พยายาม</media:title>
		</media:content>

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/image/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/image/notepad/notepad1.gif" medium="image">
			<media:title type="html">พยายาม</media:title>
		</media:content>

		<media:content url="http://www.pyayam.com/java/image/notepad/notepad2.gif" medium="image">
			<media:title type="html">พยายาม</media:title>
		</media:content>

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/image/asd" medium="image" />

		<media:content url="http://www.pyayam.com/image/asd" medium="image" />

		<media:content url="http://www.pyayam.com/image/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/image/notepad/notepad1.gif" medium="image">
			<media:title type="html">พยายาม</media:title>
		</media:content>

		<media:content url="http://www.pyayam.com/java/image/notepad/notepad2.gif" medium="image">
			<media:title type="html">พยายาม</media:title>
		</media:content>

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/image/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/image/notepad/notepad1.gif" medium="image">
			<media:title type="html">พยายาม</media:title>
		</media:content>

		<media:content url="http://www.pyayam.com/java/image/notepad/notepad2.gif" medium="image">
			<media:title type="html">พยายาม</media:title>
		</media:content>

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/image/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/image/notepad/notepad1.gif" medium="image">
			<media:title type="html">พยายาม</media:title>
		</media:content>

		<media:content url="http://www.pyayam.com/java/image/notepad/notepad2.gif" medium="image">
			<media:title type="html">พยายาม</media:title>
		</media:content>

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/java/asd" medium="image" />

		<media:content url="http://www.pyayam.com/image/asd" medium="image" />
	</item>
		<item>
		<title>เมื่อไหร่ต้องใช้ JavaScript ?</title>
		<link>http://on006.wordpress.com/2008/07/05/%e0%b9%80%e0%b8%a1%e0%b8%b7%e0%b9%88%e0%b8%ad%e0%b9%84%e0%b8%ab%e0%b8%a3%e0%b9%88%e0%b8%95%e0%b9%89%e0%b8%ad%e0%b8%87%e0%b9%83%e0%b8%8a%e0%b9%89-javascript/</link>
		<comments>http://on006.wordpress.com/2008/07/05/%e0%b9%80%e0%b8%a1%e0%b8%b7%e0%b9%88%e0%b8%ad%e0%b9%84%e0%b8%ab%e0%b8%a3%e0%b9%88%e0%b8%95%e0%b9%89%e0%b8%ad%e0%b8%87%e0%b9%83%e0%b8%8a%e0%b9%89-javascript/#comments</comments>
		<pubDate>Sat, 05 Jul 2008 20:47:51 +0000</pubDate>
		<dc:creator>on006</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://on006.wordpress.com/?p=8</guid>
		<description><![CDATA[เราจะใช้ JavaScript เมื่อต้องการทำให้ เวบเพจแสดงผลแบบเคลื่อนไหวได้ มีชีวิตชีวา ไม่แข็งทื่อ หรือใช้ในการสั่งให้ บราวเซอร์ทำงานตามที่เราต้องการ โดยงานนั้น อาจเกินความสามารถ ของภาษา HTML แต่ไม่ใช่งานที่ต้องติดต่อกับ Server นั่นเพราะ JavaScript เป็นภาษาที่ใช้ในการเขียนโปรแกรมทางฝั่ง cliend โดยมีบราวเซอร์เป็นตัวแปลภาษานั่นเอง ตัวอย่างของงาน ที่จะต้องใช้ภาษา JavaScript เช่น - สร้างเมนูที่สามารถตอบสนองต่อการเอา mouse ไปชี้ได้ - สร้างเครื่องคิดเลข ปฏิทิน เกม ในเวบเพจ - เปิด,ปิด,เคลื่อนย้ายตำแหน่งของ window - ทำตัวอักษรวิ่งแบบต่างๆ - ตรวจสอบความถูกต้องของแบบฟอร์มที่ผู้ใช้กรอก ก่อนส่งข้อมูลไปยัง Server - และอื่นๆ อีกมากมายที่ไม่ต้องติดต่อกับ Server<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=on006.wordpress.com&amp;blog=4132251&amp;post=8&amp;subd=on006&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong> <span style="color:#008080;"> </span></strong><span style="color:#008080;">เราจะใช้ JavaScript เมื่อต้องการทำให้ เวบเพจแสดงผลแบบเคลื่อนไหวได้                มีชีวิตชีวา ไม่แข็งทื่อ หรือใช้ในการสั่งให้ บราวเซอร์ทำงานตามที่เราต้องการ                โดยงานนั้น อาจเกินความสามารถ ของภาษา HTML แต่ไม่ใช่งานที่ต้องติดต่อกับ                Server นั่นเพราะ JavaScript เป็นภาษาที่ใช้ในการเขียนโปรแกรมทางฝั่ง                cliend โดยมีบราวเซอร์เป็นตัวแปลภาษานั่นเอง ตัวอย่างของงาน ที่จะต้องใช้ภาษา                JavaScript</span><span id="more-8"></span> เช่น</p>
<blockquote>
<p align="justify">- สร้างเมนูที่สามารถตอบสนองต่อการเอา mouse ไปชี้ได้<br />
- สร้างเครื่องคิดเลข ปฏิทิน เกม ในเวบเพจ<br />
- เปิด,ปิด,เคลื่อนย้ายตำแหน่งของ window<br />
- ทำตัวอักษรวิ่งแบบต่างๆ<br />
- ตรวจสอบความถูกต้องของแบบฟอร์มที่ผู้ใช้กรอก ก่อนส่งข้อมูลไปยัง                  Server<br />
- และอื่นๆ อีกมากมายที่ไม่ต้องติดต่อกับ Server</p></blockquote>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/on006.wordpress.com/8/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/on006.wordpress.com/8/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/on006.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/on006.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/on006.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/on006.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/on006.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/on006.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/on006.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/on006.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/on006.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/on006.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/on006.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/on006.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/on006.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/on006.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=on006.wordpress.com&amp;blog=4132251&amp;post=8&amp;subd=on006&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://on006.wordpress.com/2008/07/05/%e0%b9%80%e0%b8%a1%e0%b8%b7%e0%b9%88%e0%b8%ad%e0%b9%84%e0%b8%ab%e0%b8%a3%e0%b9%88%e0%b8%95%e0%b9%89%e0%b8%ad%e0%b8%87%e0%b9%83%e0%b8%8a%e0%b9%89-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fd2f2b343fea71db0292fe37b17dcbd6?s=96&#38;d=identicon" medium="image">
			<media:title type="html">on006</media:title>
		</media:content>
	</item>
		<item>
		<title>วัดอุณหภูมิและความชื้นด้วย C# ตอน 2 (ตอนจบ)</title>
		<link>http://on006.wordpress.com/2008/07/05/%e0%b8%a7%e0%b8%b1%e0%b8%94%e0%b8%ad%e0%b8%b8%e0%b8%93%e0%b8%ab%e0%b8%a0%e0%b8%b9%e0%b8%a1%e0%b8%b4%e0%b9%81%e0%b8%a5%e0%b8%b0%e0%b8%84%e0%b8%a7%e0%b8%b2%e0%b8%a1%e0%b8%8a%e0%b8%b7%e0%b9%89%e0%b8%99-2/</link>
		<comments>http://on006.wordpress.com/2008/07/05/%e0%b8%a7%e0%b8%b1%e0%b8%94%e0%b8%ad%e0%b8%b8%e0%b8%93%e0%b8%ab%e0%b8%a0%e0%b8%b9%e0%b8%a1%e0%b8%b4%e0%b9%81%e0%b8%a5%e0%b8%b0%e0%b8%84%e0%b8%a7%e0%b8%b2%e0%b8%a1%e0%b8%8a%e0%b8%b7%e0%b9%89%e0%b8%99-2/#comments</comments>
		<pubDate>Sat, 05 Jul 2008 20:42:27 +0000</pubDate>
		<dc:creator>on006</dc:creator>
				<category><![CDATA[C# และ .NET]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://on006.wordpress.com/?p=7</guid>
		<description><![CDATA[วัดอุณหภูมิและความชื้นด้วย C# ตอน 2 (ตอนจบ) เขียนโปรแกรมภาษา C# ใน .NET Framework นิยามคลาสวัดอุณหภูมิและความชื้นที่นำไปใช้ได้ทั้งใน WinForm และ WebForm ตอนจบ ที่ท่านกำลังอ่านอยู่นี้คือตอนที่สองซึ่งเป็นตอนสุดท้ายของบทความนี้ ในตอนที่แล้วผู้เขียนพูดถึงฮาร์ดแวร์ที่ใช้ในโครงงานวิธีนำอุปกรณ์มาเชื่อมต่อกัน วิธีที่อุปกรณ์ดังกล่าวกับคอมพิวเตอร์สื่อสารกัน และวิธีเขียนคำสั่งควบคุมอุปกรณ์ นอกจากนั้นผู้เขียนยังอธิบายวิธีนิยามคลาส TempReader เพื่อห่อหุ้มอุปกรณ์และพอร์ทอนุกรมไว้เป็นก้อนเดียวกัน แต่อธิบายไปได้แค่สมาชิกแบบ field ก็หมดหน้ากระดาษ ดังนั้นในบทความตอนนี้เราจะมาดูนิยามส่วนที่เหลือทั้งหมด และปิดท้ายด้วยวิธีนำคลาส TempReader ไปใช้สร้าง object เพื่อทำหน้าที่วัดอุณหภูมิและความชื้นที่นำไปใช้ได้ทั้งใน WinForm และ WebForm กระประกาศสมาชิก property สมาชิกแบบ property ทำให้ object และ client class รับ-ส่งข้อมูลกันได้ อันที่จริงเราอาจเขียนโปรแกรมให้ client class อ่านและเขียนค่ากับฟิลด์สมาชิกของ object โดยตรงก็ได้ แต่ไม่สู้เป็นที่นิยม เพราะการทำเช่นนั้นผิดหลักการ encapsulation ซึ่งไม่ต้องการให้ client [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=on006.wordpress.com&amp;blog=4132251&amp;post=7&amp;subd=on006&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span><span style="font-size:large;font-family:Courier New;color:#0080ff;"><strong>วัดอุณหภูมิและความชื้นด้วย C# ตอน 2 (ตอนจบ) </strong></span></p>
<p><span style="font-size:small;font-family:Courier New;">เขียนโปรแกรมภาษา C# ใน .NET Framework นิยามคลาสวัดอุณหภูมิและความชื้นที่นำไปใช้ได้ทั้งใน WinForm และ WebForm ตอนจบ </span></p>
<p><span style="font-size:small;font-family:Courier New;"><span style="color:#400040;">ที่ท่านกำลังอ่านอยู่นี้คือตอนที่สองซึ่งเป็นตอนสุดท้ายของบทความนี้ ในตอนที่แล้วผู้เขียนพูดถึงฮาร์ดแวร์ที่ใช้ในโครงงานวิธีนำอุปกรณ์มาเชื่อมต่อกัน วิธีที่อุปกรณ์ดังกล่าวกับคอมพิวเตอร์สื่อสารกัน และวิธีเขียนคำสั่งควบคุมอุปกรณ์ นอกจากนั้นผู้เขียนยังอธิบายวิธีนิยามคลาส TempReader เพื่อห่อหุ้มอุปกรณ์และพอร์ทอนุกรมไว้เป็นก้อนเดียวกัน แต่อธิบายไปได้แค่สมาชิกแบบ field ก็หมดหน้ากระดาษ ดังนั้นในบทความตอนนี้เราจะมาดูนิยามส่วนที่เหลือทั้งหมด และปิดท้ายด้วยวิธีนำคลาส TempReader ไปใช้สร้าง object เพื่อทำหน้าที่วัดอุณหภูมิและความชื้นที่นำไปใช้ได้ทั้งใน WinForm และ WebForm</span></span><span id="more-7"></span></p>
<p><span style="font-size:small;font-family:Courier New;"><strong><span style="color:#0080ff;">กระประกาศสมาชิก property</span></strong> </span></p>
<p><span style="font-size:small;font-family:Courier New;">สมาชิกแบบ property ทำให้ object และ client class รับ-ส่งข้อมูลกันได้ อันที่จริงเราอาจเขียนโปรแกรมให้ client class อ่านและเขียนค่ากับฟิลด์สมาชิกของ object โดยตรงก็ได้ แต่ไม่สู้เป็นที่นิยม เพราะการทำเช่นนั้นผิดหลักการ encapsulation ซึ่งไม่ต้องการให้ client class เข้าถึงข้อมูลภายใน object โดยตรง แต่ให้เข้าถึงทางอ้อมผ่านส่วนกันชน </span></p>
<p><span style="font-size:small;font-family:Courier New;">คลาส TempReader มีประกาศสมาชิก property เพียงตัวเดียวคือ TemppComPort ทำหน้าที่ให้ client class สามารถกำหนด และตรวจดูหมายเลขพอร์ทอนุกรมได้ เมื่อ client class ต้องการกำหนดค่าพอร์ท มันจะส่งค่าให้แก่ property นี้ ซึ่งจะนำค่าที่ได้รับมาไปกำหนดให้กับ ฟิลด์สมาชิก temppComPort อีกทอดหนึ่ง เมื่อ client class ต้องการอ่านค่าพอร์ท มันจะอ่านค่าจาก property นี้ ซึ่งจะนำค่าของฟิลด์สมาชิก temppComPort ส่งกลับไปให้ </span></p>
<p><span style="font-size:small;font-family:Courier New;color:#0080ff;"><strong>นิยามส่วน method สมาชิก </strong></span></p>
<p><span style="font-size:small;font-family:Courier New;">Method ในภาษา C# คล้ายฟังก์ชันในภาษาซีหรือภาษา JavaScript คือเป็นกลุ่มโค้ดทำหน้าที่ประมวลผลบางอย่าง ในภาษา C# ไม่มี method ที่อยู่อย่างเอกเทศเหมือนภาษาซี method ทุก method ต้องเป็นสมาชิกของคลาสหรือ struct เท่านั้น </span></p>
<p><span style="font-size:small;font-family:Courier New;">หากท่านดูโค้ดส่วนนิยาม method สมาชิกของคลาส TempReader จะเห็นว่ามีสี่ตัวดังนี้ </span></p>
<p><span style="font-size:small;font-family:Courier New;">• GetTempp : ทำหน้าที่ส่งคำสั่งไปยัง AP170<br />
• CloseCom : ทำหน้าที่ปิดพอร์ท<br />
• CreateTemppConnection : ทำหน้าที่กำหนดค่าเริ่มต้นของพอร์ท<br />
• myTemppComPort_DataReceived : ทำงานเมื่อพอร์ทได้รับข้อมูลจาก AP170 </span></p>
<p><span style="font-size:small;font-family:Courier New;">ต่อไปนี้ผู้เขียนจะอธิบายโค้ดของ method แต่ละตัว </span></p>
<p><span style="font-size:small;font-family:Courier New;color:#0080ff;"><strong>GetTempp </strong></span></p>
<p><span style="font-size:small;font-family:Courier New;">Method GetTempp ทำหน้าที่ส่งคำสั่งไปยัง AP170 เพราะเมื่อเราต้องการอ่านค่าอุณหภูมิและความชื้น เราจะต้องส่งคำสั่งไปยัง AP170 การส่งคำสั่งทำได้โดยส่งกลุ่มตัวอักษรคำสั่งออกไปทางพอร์ทอนุกรม ยกตัวอย่างเช่น หากต้องการอ่านค่าอุณหภูมิและความชื้น เราต้องส่ง string ต่อไปนี้ “:1\r” ไปที่พอร์ทอนุกรม </span></p>
<p><span style="font-size:small;font-family:Courier New;">เนื่องจากเราสร้าง object พอร์ทอนุกรมไว้แล้ว การส่งกลุ่มตัวอักษรคำสั่งออกไปทางพอร์ทอนุกรมจึงทำได้ง่ายมาก เพียงเรียกใช้ method ชื่อ Write โปรดสังเกตว่า method ชื่อ Write เป็น method ที่เราไม่ได้นิยามเอง แต่เป็น method สมาชิกของคลาส SerialPort ที่ .NET Framework จัดเตรียมไว้ให้ </span></p>
<p><span style="font-size:small;font-family:Courier New;">คำสั่ง if (!myTemppComPort.IsOpen) myTemppComPort.Open(); ทำหน้าที่ตรวจสอบว่าขณะนี้พอร์ทอนุกรมเปิดอยู่หรือไม่ หากพอร์ทยังไม่เปิดแล้วเราเรียก method Write จะเกิด run-time error เราจึงต้องเปิดพอร์ทเสียก่อน เมื่อเปิดแล้วและส่งคำสั่งเสร็จแล้ว เราจะไม่ปิดพอร์ท เราจำเป็นต้องเปิดพอร์ททิ้งไว้เพื่อรอรับข้อมูลที่ AP170 จะส่งกลับมา </span></p>
<p><span style="font-size:small;font-family:Courier New;color:#0080ff;"><strong>CloseCom </strong></span></p>
<p><span style="font-size:small;font-family:Courier New;">Method CloseCom ทำหน้าที่ปิดพอร์ท มีสองเหตุการณ์ที่เราจำเป็นต้องปิดพอร์ทอนุกรม เหตุการณ์แรกคือเมื่อผู้ใช้เปลี่ยนค่ากำหนดของพอร์ทสื่อสาร เช่นหากผู้ใช้ต้องการเปลี่ยนความเร็ว จำนวนพาริตีบิต หรือเปลี่ยนหมายเลขพอร์ท เราจะต้องปิดพอร์ทเสียก่อน ในอีกกรณีหนึ่งคือเมื่อจบการทำงานของโปรแกรม เราควรปิดพอร์ทอนุกรมเพื่อให้โปรแกรมอื่นๆ สามารถเรียกใช้พอร์ทได้ </span></p>
<p><span style="font-size:small;font-family:Courier New;">คำสั่ง myTemppComPort.Close();ทำหน้าที่เรียก method Close ซึ่งเป็น method สมาชิกของคลาส SerialPort เช่นเดียวกับ method Write </span></p>
<p><span style="font-size:small;font-family:Courier New;color:#0080ff;"><strong>CreateTemppConnection </strong></span></p>
<p><span style="font-size:small;font-family:Courier New;">Method CreateTemppConnection ทำหน้าที่กำหนดค่าเริ่มต้นของพอร์ท การกำหนดทำได้โดยเซท property ต่างๆ ของ object พอร์ทอนุกรม ค่าที่เราควรกำหนดก่อนใช้งานพอร์ทอนุกรมมีดังต่อไปนี้ </span></p>
<ul>
<li><span style="font-size:small;font-family:Courier New;"><strong>BaudRate:</strong> ทำหน้าที่กำหนดความเร็วในการสื่อสาร เนื่องจาก AP170 ทำงานที่ความเร็ว 9600 เราจึงต้องตั้งค่า baud rate ให้ตรงตามนั้น</span></li>
<li><span style="font-size:small;font-family:Courier New;"><strong>PortName:</strong> เราต้องกำหนดชื่อพอร์ทที่จะใช้งานในรูปแบบข้อความดังนี้ “COM1” คำว่า “COM” เป็นข้อความตายตัวจึงใส่ไว้ในโค้ดได้เลย ส่วนตัวเลขที่ตามหลังอาจเป็นไปได้ตั้งแต่ 1 ถึง 6 ซึ่งเราต้องการให้ผู้ใช้กำหนดได้ จึงทำเป็น property ชื่อ TemppComPort ไว้ดังที่อธิบายไปแล้ว </span><span style="font-size:small;font-family:Courier New;">เพื่อป้องกันไม่ให้เกิด error หาก client class เรียก Method CreateTemppConnection โดยไม่ได้เซทค่า property TemppComPort ไว้ก่อน เราจึงต้องกำหนดค่าโดยปริยายของฟิลด์สมาชิก temppComPort ให้เป็น 1 ไว้ตอนประกาศที่ส่วนหัวของโปรแกรม </span></li>
<li><span style="font-size:small;font-family:Courier New;"><strong>Parity:</strong> พาริตี เป็นกลไกเพื่อตรวจสอบความถูกต้องของข้อมูลโดยแทรกบิตที่เป็นหนึ่งหรือศูนย์เข้าไปในข้อมูล เนื่องจาก AP170 ไม่ใช้งานพาริตี เราจึงกำหนดให้เป็น None คือไม่แทรกบิต </span></li>
<li><span style="font-size:small;font-family:Courier New;"><strong>DataBits:</strong> ทำหน้าที่กำหนดจำนวนบิตของข้อมูลหนึ่งไบต์ AP170 มีมาตรฐานการรับ-ส่งข้อมูล 8 บิตต่อหนึ่งไบต์ เราจึงต้องกำหนดให้เป็นตามนั้น </span></li>
<li><span style="font-size:small;font-family:Courier New;"><strong>StopBits:</strong> ทำหน้าที่กำหนดบิตปิดท้ายข้อมูลที่รับ-ส่งแต่ละไบต์ AP170 มีมาตรฐานการรับ-ส่งแบบ 1 stop bit เราจึงต้องกำหนดให้เป็นตามนั้น </span></li>
<li><span style="font-size:small;font-family:Courier New;"><strong>DataReceived:</strong> ทำหน้ากำหนด method ที่เราต้องการให้โปรแกรมทำงานเมื่อพอร์ทสื่อสารได้รับข้อมูล ในที่นี้เรากำหนดว่าให้ไปทำงานที่ method ชื่อ myTemppComPort_DataReceived </span></li>
</ul>
<p><span style="font-size:small;font-family:Courier New;">ขอให้สังเกตว่าก่อนที่เราจะกำหนดค่าเหล่านี้เราต้องปิดพอร์ทเสียก่อน โดยเรียก method CloseCom </span></p>
<p><span style="font-size:small;font-family:Courier New;"><strong><span style="color:#0080ff;">myTemppComPort_DataReceived</span> </strong></span></p>
<p><span style="font-size:small;font-family:Courier New;">โค้ดส่วนสุดท้ายในคลาส TempReader คือ method myTemppComPort_DataReceived เป็น method ทำหน้าที่ให้บริการ event ซึ่งจะทำงานเมื่อพอร์ทอนุกรมได้รับข้อมูลจาก AP170 คำสั่ง rxString += myTemppComPort.ReadExisting(); ทำหน้าที่เรียก method ชื่อ ReadExisting() ซึ่งเป็น method สมาชิกของคลาส SerialPort ทำหน้าที่นำข้อมูลซึ่งอยู่ใน input buffer ทั้งหมดในขณะนั้นมาให้เรา ซึ่งเรานำมาเก็บพักไว้ในฟิลด์สมาชิก rxString </span></p>
<p><span style="font-size:small;font-family:Courier New;">คำสั่งบรรทัดต่อมา if (rxString[rxString.Length-1] == &#8216;\r&#8217; ) ทำหน้าที่ตรวจสอบว่าข้อมูลที่ได้รับมาครบแล้วหรือยัง ซึ่งตรวจสอบโดยดูว่าตัวอักษรสุดท้ายของข้อมูลเป็นรหัส return code หรือไม่ หากไม่ใช่แสดงว่าข้อมูลยังมาไม่ครบ โปรแกรมจะออกจาก method นี้เพื่อไปรอรับข้อมูลเพิ่ม </span></p>
<p><span style="font-size:small;font-family:Courier New;">เมื่อข้อมูลมาครบดีแล้ว โปรแกรมจะทำงานคำสั่ง TemppReaderFire(rxString); ซึ่งเป็น anonymous method ที่เราประกาศไว้โดย delegate และ event ที่หัวโปรแกรม เนื่องจาก method นี้ไม่ได้มีอยู่จริง เมื่อโปรแกรมทำงานบรรทัดนี้ CLR (Common Language Runtime ของ .NET Framework) จะส่ง event ที่จะทำให้ method ใน client class (ที่เราต้องเขียนเตรียมไว้) ทำงานแทน </span></p>
<p><span style="font-size:small;font-family:Courier New;">โค้ดของคลาส TemppReader ซึ่งมีหน้าที่เป็นพิมพ์เขียวของ object ห่อหุ้มการทำงานของพอร์ทอนุกรมและ AP170 มีเพียงเท่านี้ ต่อไปเป็นโค้ดส่วน client class ซึ่ง ทำหน้าที่ทดสอบใช้งาน object นี้ </span></p>
<p><span style="font-size:small;font-family:Courier New;color:#0080ff;"><strong>วิธีใช้งาน object </strong></span></p>
<p><span style="font-size:small;font-family:Courier New;">ต่อไปเราจะสร้าง WinForm เพื่อสาทิตการทำงานของ object ห่อหุ้มการทำงานของพอร์ทอนุกรมและ AP170 ที่เรานิยามคลาสไปแล้วในหัวข้อก่อน หน้า WinForm ที่เราจะสร้างเพื่อทดสอบนี้เรียบง่าย มี control เพียงสองตัวคือ Label ทำหน้าที่แสดงข้อมูล และปุ่มทำหน้าที่ส่งคำสั่งอ่านข้อมูลไปยัง AP170 </span></p>
<p><a href="http://by1.storage.msn.com/y1p2A1sE9nJDcN-Vi7-vE3o4Zu9YsKqeRtFxvvlkO7tCliD69Qcdy1Kty5p2YmaavVSdKvxMbF7HtQs8yNBkeu6mg"><img src="http://by1.storage.msn.com/y1p2A1sE9nJDcM9mo-Q39MQhmdFA3MzGrnUrlHFGThxOZ8GH5UgjtHiGd49H2FkhfLIn2Mvbm3Q5Ai_a1oOEoxcRg" alt="" width="353" height="144" /></a></p>
<p><span style="font-size:small;font-family:Courier New;"><span style="color:#800000;">หน้า WinForm ที่สร้างเพื่อทดสอบมี control เพียงสองตัวคือ Label ทำหน้าที่แสดงข้อมูล และปุ่มทำหน้าที่ส่งคำสั่งอ่านข้อมูลไปยัง AP170</span> </span></p>
<p><span style="font-size:small;font-family:Courier New;">หน้า WinForm ที่เราจะสร้างมีฐานะเป็นคลาส มีโค้ดทั้งหมดดังนี้ </span></p>
<pre>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Laploy.TempHumReader
{
    public partial class test : Form
    {
        delegate void SetCallback(string text);
        private TemppReader myTemppReader1;

        public test()
        {
            InitializeComponent();
        }
        private void test_Load(object sender, EventArgs e)
        {
            myTemppReader1 = new TemppReader();
            myTemppReader1.TemppComPort = 1;
            myTemppReader1.TemppReaderFire += new
            TemppReader.TemppReaderEventHandler(myTemppReader1_TemppReaderFire);
            myTemppReader1.CreateTemppConnection();
        }
        private void myTemppReader1_TemppReaderFire(string tempp)
        {
            ShowText(tempp);
        }
        private void ShowText(string text)
        {
            if (label1.InvokeRequired)
            {
                SetCallback myCallBack = new SetCallback(ShowText);
                Invoke(myCallBack, new object[] { text });
            }
            else
            {
                label1.Text = text;
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            myTemppReader1.GetTempp(":011\r");
        }
    }
} 

<span style="font-size:small;font-family:Courier New;"><a href="http://by1.storage.msn.com/y1p2A1sE9nJDcPLCDkbBNrycNtH5UvKLkvudMRtebHfCnw9CfX2Qw6Rn3FsbXsvlOHpNj6E_uNx1UpHSH-aMiJAfT6-T0B7DRuH"><img src="http://by1.storage.msn.com/y1p2A1sE9nJDcOhQvtT3nKhNtsxU9ZsWbHNR0vq_XY-0HS_ZI3qJMRzK-p9GS5_dCbTKv_Ijf5xP3YJmsrHxgRSM7rBdFcEUuXD" alt="" width="267" height="388" /></a> </span>
<span style="font-size:small;font-family:Courier New;color:#800000;">คลาสไดอะแกรมของ test </span></pre>
<p><span style="font-size:small;font-family:Courier New;">จากคลาสไดอะแกรมของคลาส test จะเห็นว่ามีฟิลด์สมาชิก สี่ตัว button1, components และ label1 เป็น control ตัวอักษรมีสีอ่อนเพื่อบอกให้รู้ว่าเป็นโค้ดที่ถูกสร้างโดยโปรแกรม Visual Studio .NET ส่วน myTemppReader1 เป็นฟิลด์ที่เรานิยามขึ้นเอง </span></p>
<p><span style="font-size:small;font-family:Courier New;">คลาส test มี method สมาชิกรวมทั้งสิ้น 7 ตัว สองตัวคือ Dispose และ InitializerComponent เป็น method ที่ถูกสร้างขึ้นโดยอัตโนมัติจากโปรแกรม Visual Studio .NET </span></p>
<p><span style="font-size:small;font-family:Courier New;">โปรดสังเกตว่าคลาส test ไม่มีสมาชิกแบบ property เพราะเป็นคลาสแบบ WinForm ไม่ใชjคลาสที่เรานิยามขึ้นเพื่อสร้าง object </span></p>
<p><span style="font-size:small;font-family:Courier New;">โปรแกรมใน .NET Framework นอกจากจะมีคุณสมบัติ type safety แล้ว ยังมีคุณสมบัติ thread safety อีกด้วย ในโปรแกรมของเรา object ที่เราสร้างจากคลาส SerialPort จะวิ่งอยู่ในอีก thread หนึ่งแยกต่างหากจาก thread ของตัว WinForm ทำให้เรานำข้อมูลจาก SerialPort มาแสดงใน label ใน WinForm โดยตรงไม่ได้ เพราะเป็นการทำงานข้าม thread ผู้เขียนแก้ปัญหานี้โดยใช้ delegate และ Invoke </span></p>
<p><span style="font-size:small;font-family:Courier New;">คำสั่ง delegate void SetCallback(string text); ประกาศ method ที่จะใช้ในการ call back โปรดสังเกตว่า delegate ตัวนี้ไม่มีอะไรเกี่ยวข้องกับ delegate ในคลาส TemppReader ที่เราใช้ delegate ร่วมกับ event เพื่อสร้างการ call back กับ client class (คือหน้า WinForm นี้) แต่ในคลาส test นี้เราใช้ delegate ร่วมกับคำสั่ง Invoke เพื่อแก้ปัญหาการทำงานข้าม thread </span></p>
<p><span style="font-size:small;font-family:Courier New;">คำสั่ง private TemppReader myTemppReader1; ทำหน้าที่สร้าง object ที่ห่อหุ้มการทำงานของพอร์ทอนุกรมและ AP170 ดังที่อธิบายไปแล้ว </span></p>
<p><span style="font-size:small;font-family:Courier New;">ถัดมาคือ public test() เป็น constructor ทำหน้าที่กำหนดค่าเริ่มต้นต่างๆ ให้แก่ WinForm บรรทัดต่อมาคำสั่ง private void test_Load(object sender, EventArgs e) คือนิยาม method บริการ event Load ซึ่งจะเกิดขึ้นเมื่อหน้า WinForm ถูกเปิดขึ้น ผู้เขียนใส่คำสั่งกำหนดค่าต่างๆ ให้แก่ myTemppReader1 </span></p>
<p><span style="font-size:small;font-family:Courier New;">คำสั่งสำคัญที่ควรสังเกตคือ คำสั่งบรรทัดนี้ </span></p>
<p><span style="font-size:x-small;font-family:Courier New;color:#000040;">myTemppReader1.TemppReaderFire += new TemppReader.TemppReaderEventHandler(myTemppReader1_TemppReaderFire);<br />
</span></p>
<p><span style="font-size:small;font-family:Courier New;">คำสั่งนี้ทำหน้าที่กำหนดให้โปรแกรมไปทำงานที่ method ชื่อ myTemppReader1_TemppReaderFire เมื่อ myTemppReader1 ส่ง event ชื่อ TemppReaderFire ซึ่งจะเกิดขึ้นเมื่อเราได้รับข้อมูลจาก AP170 </span></p>
<p><span style="font-size:small;font-family:Courier New;">นี่คือผลลัพธ์ของการที่เราสร้าง delegate และ event ไว้ในคลาส TemppReader นี่คือวิธีการที่ object เรียก method ใน client class ให้ทำงานได้เหมือนการทำ function pointer ในภาษา C++ เป็นวิธีสร้างและใช้งาน call back ในสไตล์ภาษา C# </span></p>
<p><span style="font-size:small;font-family:Courier New;">ผู้เขียนอยากจะอธิบายโค้ดภายในคลาส test ละเอียดกว่านี้ แต่ทำไม่ได้เพราะหมดพื้นที่หน้ากระดาษเสียแล้ว อย่างไรก็ดีเท่าที่อธิบายมาโดยสังเขปนี้ ท่านน่าจะได้รับข้อมูลเพียงพอที่ไปทดลองใช้งานดูได้แล้ว หากมีข้อสงสัยใดๆ กรุณาโพสคำถามของท่านไว้ที่ wwwlaploy.com ผู้เขียนจะตอบทุกคำถามอย่างดีที่สุด</span></p>
<p><span style="font-size:x-small;font-family:Courier New;color:#808080;">บทความนี้นำมาจาก นิตยสาร Windows IT Pro เขียนโดย ลาภลอย วานิชอังกูร (laploy.com)</span></p>
<p></span></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/on006.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/on006.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/on006.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/on006.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/on006.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/on006.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/on006.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/on006.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/on006.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/on006.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/on006.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/on006.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/on006.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/on006.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/on006.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/on006.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=on006.wordpress.com&amp;blog=4132251&amp;post=7&amp;subd=on006&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://on006.wordpress.com/2008/07/05/%e0%b8%a7%e0%b8%b1%e0%b8%94%e0%b8%ad%e0%b8%b8%e0%b8%93%e0%b8%ab%e0%b8%a0%e0%b8%b9%e0%b8%a1%e0%b8%b4%e0%b9%81%e0%b8%a5%e0%b8%b0%e0%b8%84%e0%b8%a7%e0%b8%b2%e0%b8%a1%e0%b8%8a%e0%b8%b7%e0%b9%89%e0%b8%99-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fd2f2b343fea71db0292fe37b17dcbd6?s=96&#38;d=identicon" medium="image">
			<media:title type="html">on006</media:title>
		</media:content>

		<media:content url="http://by1.storage.msn.com/y1p2A1sE9nJDcM9mo-Q39MQhmdFA3MzGrnUrlHFGThxOZ8GH5UgjtHiGd49H2FkhfLIn2Mvbm3Q5Ai_a1oOEoxcRg" medium="image" />

		<media:content url="http://by1.storage.msn.com/y1p2A1sE9nJDcOhQvtT3nKhNtsxU9ZsWbHNR0vq_XY-0HS_ZI3qJMRzK-p9GS5_dCbTKv_Ijf5xP3YJmsrHxgRSM7rBdFcEUuXD" medium="image" />
	</item>
		<item>
		<title>วัดอุณหภูมิและความชื้นด้วย C# ตอน 1</title>
		<link>http://on006.wordpress.com/2008/07/05/%e0%b8%a7%e0%b8%b1%e0%b8%94%e0%b8%ad%e0%b8%b8%e0%b8%93%e0%b8%ab%e0%b8%a0%e0%b8%b9%e0%b8%a1%e0%b8%b4%e0%b9%81%e0%b8%a5%e0%b8%b0%e0%b8%84%e0%b8%a7%e0%b8%b2%e0%b8%a1%e0%b8%8a%e0%b8%b7%e0%b9%89%e0%b8%99/</link>
		<comments>http://on006.wordpress.com/2008/07/05/%e0%b8%a7%e0%b8%b1%e0%b8%94%e0%b8%ad%e0%b8%b8%e0%b8%93%e0%b8%ab%e0%b8%a0%e0%b8%b9%e0%b8%a1%e0%b8%b4%e0%b9%81%e0%b8%a5%e0%b8%b0%e0%b8%84%e0%b8%a7%e0%b8%b2%e0%b8%a1%e0%b8%8a%e0%b8%b7%e0%b9%89%e0%b8%99/#comments</comments>
		<pubDate>Sat, 05 Jul 2008 20:39:26 +0000</pubDate>
		<dc:creator>on006</dc:creator>
				<category><![CDATA[C# และ .NET]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://on006.wordpress.com/?p=6</guid>
		<description><![CDATA[เขียนโปรแกรมภาษา C# ใน .NET Framework นิยามคลาสวัดอุณหภูมิและความชื้นที่นำไปใช้ได้ทั้งใน WinForm และ WebForm งานที่ผู้เขียนกำลังทำอยู่ตอนนี้คือ ระบบเก็บข้อมูลเพื่อวิเคราะห์สาเหตุความขัดข้องของอุปกรณ์อิเลคทรอนิคส์ ข้อมูลที่เก็บมีหลายอย่างหลายรายการ ข้อมูลสำคัญอย่างหนึ่งที่อาจเป็นสาเหตุของความขัดข้องก็คือความร้อนและความชื้น ปัญหาคืออุปกรณ์อิเลคทรอนิคส์ดังกล่าวถูกติดตั้งไว้กลางแจ้ง ในถิ่นทุรกันดาร เช่นตามทุ่งนาป่าเขา ยากแก่การเข้าไปตรวจสอบ ผู้เขียนแก้ปัญหาโดยจัดทำระบบตรวจวัดอุณหภูมิและความชื้น แล้วส่งข้อมูลเหล่านี้เข้าสู่เครือข่ายอินเตอร์เน็ต ทำให้เฝ้าติดตามสถานะจากทางไกลได้ โปรแกรมส่วน client เป็น thin client คือใช้ web browser เป็นตัวเปิด web application มีโปรแกรมทั้งส่วน client และส่วน server โปรแกรมส่วน server ใช้เทคโนโลยี ASP.NET และภาษา C# โปรแกรมส่วน client ใช้ภาษา JavaScript ทำงานประสานกับโปรแกรมภาษา C# ในฝั่ง server โดยใช้กลไก Ajax ทำให้แสดงข้อมูลได้อย่างมีพลวัต ตัวเลขและแผนภูมิถูก update อัตโนมัติทุกนาทีโดยไม่ต้องโหลดหน้าเว็บ [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=on006.wordpress.com&amp;blog=4132251&amp;post=6&amp;subd=on006&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span><span style="font-size:medium;font-family:Courier New;color:#808080;"><span style="color:#ff0000;">เขียนโปรแกรมภาษา C# ใน .NET Framework นิยามคลาสวัดอุณหภูมิและความชื้นที่นำไปใช้ได้ทั้งใน WinForm และ WebForm</span> </span></span></p>
<p><span style="font-size:small;font-family:Courier New;">งานที่ผู้เขียนกำลังทำอยู่ตอนนี้คือ ระบบเก็บข้อมูลเพื่อวิเคราะห์สาเหตุความขัดข้องของอุปกรณ์อิเลคทรอนิคส์ ข้อมูลที่เก็บมีหลายอย่างหลายรายการ ข้อมูลสำคัญอย่างหนึ่งที่อาจเป็นสาเหตุของความขัดข้องก็คือความร้อนและความชื้น ปัญหาคืออุปกรณ์อิเลคทรอนิคส์ดังกล่าวถูกติดตั้งไว้กลางแจ้ง ในถิ่นทุรกันดาร เช่นตามทุ่งนาป่าเขา ยากแก่การเข้าไปตรวจสอบ</span><span id="more-6"></span></p>
<p><span style="font-size:small;font-family:Courier New;">ผู้เขียนแก้ปัญหาโดยจัดทำระบบตรวจวัดอุณหภูมิและความชื้น แล้วส่งข้อมูลเหล่านี้เข้าสู่เครือข่ายอินเตอร์เน็ต ทำให้เฝ้าติดตามสถานะจากทางไกลได้ โปรแกรมส่วน client เป็น thin client คือใช้ web browser เป็นตัวเปิด web application มีโปรแกรมทั้งส่วน client และส่วน server </span></p>
<p><span style="font-size:small;font-family:Courier New;">โปรแกรมส่วน server ใช้เทคโนโลยี ASP.NET และภาษา C# โปรแกรมส่วน client ใช้ภาษา JavaScript ทำงานประสานกับโปรแกรมภาษา C# ในฝั่ง server โดยใช้กลไก Ajax ทำให้แสดงข้อมูลได้อย่างมีพลวัต ตัวเลขและแผนภูมิถูก update อัตโนมัติทุกนาทีโดยไม่ต้องโหลดหน้าเว็บ </span></p>
<p><a href="http://byfiles.storage.msn.com/y1pZRw2KH8yHQUwJtJHuC6taI3S6ndCYDXj9RruAdG3IMJtOBul682jEQdxYbSTCeNDApb6r57i8RU"><img style="border-width:0;" src="http://byfiles.storage.msn.com/y1pZRw2KH8yHQW5-mw3enY11y2KhfdInZXrbpSX9nZUOmUwAhpcVatoMY5lkpJOEjsYZrIAWdtsjYo" border="0" alt="" width="584" height="480" /></a></p>
<p><span style="font-size:small;font-family:Courier New;"><span style="color:#800000;">รูป 001 โปรแกรมส่วน client ใช้ภาษา JavaScript ทำงานประสานกับโปรแกรมภาษา C# ในฝั่ง server โดยใช้กลไก Ajax ทำให้แสดงข้อมูลได้อย่างมีพลวัต</span> </span></p>
<p><span style="font-size:small;font-family:Courier New;">เรื่องการทำ remote และ Ajax ผู้เขียนจะเล่าให้ฟังวันหลัง สำหรับเรื่องที่จะเล่าสูกันฟังวันนี้คือส่วนฮาร์ดแวร์และซอฟท์แวร์ที่ใช้เพื่อการตรวจวัดอุณหภูมิและความชื้น เป็นเรื่องของการเปลี่ยนข้อมูลทางกายภาพ ให้เป็นข้อมูลดิจิตอล แล้วเก็บบันทึกไว้เพื่อใช้ในการวิเคราะห์ หากท่านต้องทำโครงงานที่มีปัญหาลักษณะเดียวกัน อาจนำเทคนิคเหล่านี้ไปประยุกต์ใช้ หรืออาจเพียงแค่อ่านเล่นสนุกๆ ก็ได้ </span></p>
<p><span style="font-size:small;font-family:Courier New;">บทความนี้ท่านจะได้เรียนรู้เทคนิคการเขียนโปรแกรมในแง่มุมต่างๆ ดังนี้<br />
• การเขียนโปรแกรมภาษา C# เพื่อรับ-ส่งข้อมูลผ่านพอร์ทอนุกรม<br />
• การใช้งานไลบรารีส่วนพอร์ทอนุกรมของ .NET Framework<br />
• วิธีนิยามคลาสหุ้มห่อบอร์ดอ่านอุณหภูมิและความชื้น<br />
• การเชื่อมต่อคอมพิวเตอร์กับบอร์ดอ่านอุณหภูมิและความชื้นผ่าน RS-485<br />
• ตัวอย่างการประยุกต์ใช้งาน Delegate และ event เพื่อการทำ call back ระหว่าง object<br />
• แสดงตัวอย่างการใช้งาน anonymous method<br />
• ตัวอย่างการประยุกต์ใช้งาน Delegate และ Invoke เพื่อการทำ call back ระหว่าง thread </span></p>
<p><span style="font-size:small;font-family:Courier New;">ผู้เขียนส่งบทความนี้ให้ท่านบก. คือคุณสุวัจชัยพิจารณา บก. แจ้งว่า เนื้อหายาวเกินกว่าจะลงพิมพ์จนจบในฉบับเดียวได้ ให้ไปแยกมาเป็นสองตอน ที่ท่านกำลังอ่านอยู่นี้คือตอนแรก ผู้เขียนจะพูดถึง อุปกรณ์ คือส่วนฮาร์ดแวร์ที่เราจำเป็นต้องใช้ในโครงงานนี้ เป็นฮาร์ดแวร์ที่หาซื้อสำเร็จรูปได้ ไม่จำเป็นต้องสร้างขึ้นเอง วิธีนำอุปกรณ์มาต่อเข้าด้วยกันเป็นระบบ วิธีเขียนคำสั่งควบคุมอุปกรณ์ และวิธีที่อุปกรณ์กับคอมพิวเตอร์สื่อสารกัน จากนั้นจะพูดถึงวิธีนิยามคลาสในภาษา C# เพื่อห่อหุ้มอุปกรณ์และพอร์ทอนุกรมไว้เป็นก้อนเดียวกัน </span></p>
<p><span style="font-size:small;font-family:Courier New;"><strong>อุปกรณ์ที่ต้องใช้</strong> </span></p>
<p style="text-align:left;"><span style="font-size:small;font-family:Courier New;">ระบบนี้มีอุปกรณ์หลักๆ สี่ชิ้น คือเครื่องคอมพิวเตอร์ บอร์ดอ่านอุณหภูมิและความชื้น (ต่อไปจะเรียกย่อว่า AP170) เครื่องแปลงสัญญาณแบบ RS-232 ไปเป็น RS-485 และหัววัดอุณหภูมิและความชื้น ดังแสดงในแผนภูมินี้ </span></p>
<p style="text-align:center;"><a href="http://byfiles.storage.msn.com/y1pZRw2KH8yHQVTKSTrRrWyLRbmVw1ftRiPkJnZXwe2oiuqo1Mmg9hqEGQruJ1SlL2kqfbL_tyd1fk"><img class="aligncenter" src="http://byfiles.storage.msn.com/y1pZRw2KH8yHQWSVchA0NUoZ9w7B0CoqIMFDpDAUW72rKsHCpCML2AgW3eDzUylaClcC8kSszvsG0I" alt="" width="440" height="164" /></a></p>
<p style="text-align:center;"><span style="font-size:small;font-family:Courier New;"><span style="color:#800000;">รูป 002 แผนภูมิแสดงอุปกรณ์และการเชื่อมต่อสำหรับระบบอ่านอุณหภูมิและความชื้นกับคอมพิวเตอร์</span></span></p>
<p style="text-align:center;"><span style="font-size:small;font-family:Courier New;"><span style="color:#800000;"><br />
<a href="http://byfiles.storage.msn.com/y1pZRw2KH8yHQUhaG0jJkmG-hM2E-yzbA1hUAhTo-RG3ZJ3YYOTqUj_ZHudKtUCAaeCXnogy0LAyUE"><img class="aligncenter" style="border-width:0;" src="http://byfiles.storage.msn.com/y1pZRw2KH8yHQUGYCAfnQI1ad59xkBPmSRxafj7B-lsIZ8Mo8dXF9K_v-OT4wQcEyeiaFmn_WBV8gc" border="0" alt="" width="440" height="330" /></a> </span></span></p>
<p style="text-align:center;"><span style="font-size:small;font-family:Courier New;color:#800000;">รูป 003 ตัวแปลง RS-232/RS485</span></p>
<p style="text-align:center;"><span style="font-size:small;font-family:Courier New;"><a href="http://by1.storage.msn.com/y1p2A1sE9nJDcN4WO1Ke7bwFVBAiqQuobxuNfGozDJGKDOSQnD-jz8L_yKE-ng0k3eBmV8lHfdCQs1c_FFQpP6iksz9Vn9yekYZ"><img class="aligncenter" style="border-width:0;" src="http://byfiles.storage.msn.com/y1pZRw2KH8yHQXAmczdrartkBp2HVreMs_z3NrqJ9a23GCs0rnsQiQCV7IXgJWMFMqxIHhCZ_j5og8" border="0" alt="" width="440" height="315" /></a><br />
<span style="color:#800000;">รูป 004 บอร์ดอ่านอุณหภูมิและความชื้น</span></span></p>
<p style="text-align:center;"><span style="font-size:small;font-family:Courier New;"><a href="http://by1.storage.msn.com/y1p2A1sE9nJDcP9LyPc3g7I350zKe58G8ohF-Q_aG-nczSzZofc1fueabCy7zJXhgbc_0josK--f8HqS_hFEhPkgKDgDcZtdrw5"><span style="color:#800000;"><img class="aligncenter" style="border-width:0;" src="http://by1.storage.msn.com/y1p2A1sE9nJDcM37CVC9s_RijaPV11--Iy4RbWP01F9cUMy56einM07DT592d6zBxXz4kNrpfBmmCO9vncxw2PheQ" border="0" alt="" width="440" height="330" /></span></a><span style="color:#800000;"><br />
รูป 005 หัววัดอุณหภูมิและความชื้น<br />
<a href="http://by1.storage.msn.com/y1p2A1sE9nJDcPHjqGx8hSU6uUcvUbng7g7TlqdnAdY6mTm48IXIqpHOaThuheJk3kHVSDbt3-rRlFqIPjt1-8pPsCMkFdPvOA2"><img class="aligncenter" style="border-width:0;" src="http://by1.storage.msn.com/y1p2A1sE9nJDcPnXB43frhp60wY04_dBpXnV5t54WEeNXEG4X0iqEI64N4OxMfAsh6gVgCJ3zCimgyhX_jb4u1Zh4PF0yrVnfnu" border="0" alt="" width="440" height="330" /></a> </span></span></p>
<p style="text-align:center;"><span style="font-size:small;font-family:Courier New;color:#800000;">รูป 006 เมื่อนำทั้งหมดมาต่อเชื่อมเข้าด้วยกัน </span></p>
<p><span style="font-size:small;font-family:Courier New;">อุปกรณ์ทั้งหมดผลิตขึ้นในประเทศไทย ผู้เขียนซื้อมาจากพระโขนง หัววัดเป็นแบบวัดอุณหภูมิและความชื้นได้ในตัวเดียวกัน วัดอุณหภูมิความละเอียดขั้นละ .1 องศา ให้ค่าออกมาเป็นตัวเลของศาเซลเซียส ส่วนการวัดความชื้น วัดได้ที่ความละเอียดขั้นละ 1% ให้ตัวเลขออกมาสัดส่วนร้อยละของความชื้นสัมพัทธ์ </span></p>
<p><span style="font-size:small;font-family:Courier New;">บอร์ด AP170 อันที่จริงแล้วก็คือคอมพิวเตอร์ตัวหนึ่ง เราสามารถนำ AP170 หลายๆ บอร์ดมาต่อเชื่อมโยงเป็นเครือข่ายเหมือนระบบ LAN ได้ วิธีเชื่อมโยงใช้มาตรฐานแบบ RS-485 เมื่อเราจะนำมาต่อกับพอร์ทอนุกรมซึ่งเป็นมาตรฐาน RS-232 จึงต้องแปลงสัญญาณเสียก่อน โดยใช้ตัวแปลงสัญญาณอย่างที่เห็นในรูป </span></p>
<p><span style="font-size:small;font-family:Courier New;">เมื่อนำอุปกรณ์ทั้งหมดมาต่อเชื่อมเข้าด้วยกัน และเสียบเข้ากับพอร์ทอนุกรมของคอมพิวเตอร์ ก็ถือว่าการติดตั้งส่วนฮาร์ดแวร์สำเร็จเรียบร้อย ง่ายๆ เพียงเท่านี้ งานขั้นต่อไปคือการเขียนโปรแกรมเพื่อติดต่อสื่อสารกับ AP170 </span></p>
<p><span style="font-size:small;font-family:Courier New;"><strong>กล่องดำ</strong> </span></p>
<p><span style="font-size:small;font-family:Courier New;">ปรกติคนจะนำ AP170 ไปใช้กับไมโครคอนโทรลเลอร์ แล้วเขียนโปรแกรมควบคุมด้วยภาษา แอสแซมบลี หรือภาษา ซี แต่งานนี้เราจะนำมันมาใช้กับพีซี โดยพัฒนาเป็นโปรแกรมประยุกต์ใช้งานใน Windows ด้วยภาษา C# และ .NET Framework โปรแกรมนี้จึงทำงานได้ใน Windows 98/ME/XP และ Vista </span></p>
<p><span style="font-size:small;font-family:Courier New;">ผู้เขียนจะใช้หลักการ encapsulation และ information hiding เพื่อนิยามคลาสห่อหุ้มพอร์ทสื่อสารและบอร์ด AP170 เข้าเป็นก้อนเดียวกัน เพื่อให้การนำไปใช้งานทำได้ง่าย ท่านสามารถนำคลาสนี้ไปสร้างเป็น object ที่ทำงานภายในโครงงานต่างๆ ได้ โดยไม่ต้องพะวงกับรายละเอียดปลีกย่อยทางฮาร์ดแวร์ เหมือนเราได้กล่องดำที่ไม่จำเป็นต้องรู้รายละเอียดของการทำงานภายในก็สามารถนำไปใช้งานได้ </span></p>
<p><span style="font-size:small;font-family:Courier New;"><strong>การรับ-ส่งข้อมูลกับบอร์ดวัดอุณหภูมิ</strong> </span></p>
<p><span style="font-size:small;font-family:Courier New;">AP170 มีฟังก์ชันไม่ซับซ้อน โปรโตคอลในการรับ-ส่งข้อมูลจึงเรียบง่าย การส่งคำสั่งจากพีซีไปยังบอร์ดใช้วิธีส่งเป็นตัวอักษร (เป็นสายอักขระหรือ string) เหมือนคำสั่งควบคุมโมเด็ม ยกตัวอย่างเช่น คำสั่งอ่านอุณหภูมิและความชื้นคือ “:1&lt;cr&gt;” เราเพียงแค่ส่งตัวอักษร : และ 1 และรหัสปุ่ม Enter ซึ่งในภาษา C# จะใช้ “\r” </span></p>
<p><span style="font-size:small;font-family:Courier New;">เมื่อส่งคำสั่งไปแล้ว โปรแกรมของเราจะต้องรอรับคำตอบ เพราะ AP170 จะส่งข้อมูลกลับมาภายในครึ่งวินาที โดยเป็นข้อมูลตัวอักษรที่มีรูปแบบแน่นอนดังนี้ Txxx.x Hxxx.x&lt;cr&gt; ยกตัวอย่างเช่นหากอุณหภูมิเป็นสามสิบหาจุดห้าความชื้นร้อยละห้าสิบจุดสอง ข้อมูลที่ AP170 ส่งมาจะเป็น T036.5 H50.2&lt;cr&gt; </span></p>
<p><span style="font-size:small;font-family:Courier New;"><strong>คลาสหุ้มห่อบอร์ดวัดอุณหภูมิและความชื้น</strong> </span></p>
<p><span style="font-size:small;font-family:Courier New;">คลาสที่จะนิยามนี้ชื่อ TempReader ชื่อคลาสนี้มากจากคำสองคำ คือ temperature และ Reader ถ้าท่านไม่ชอบจะเปลี่ยนชื่อเป็นอย่างอื่นก็ได้ คลาสนี้เป็นคลาสที่เบ็ดเสร็จในตัว คือไม่ได้อ้างถึงตัวแปรหรือตัวคงค่า หรือ method ของคลาสอื่นๆ ใน project เดียวกันนี้ </span></p>
<p><span style="font-size:small;font-family:Courier New;">คลาส TempReader เป็นคลาสที่ถูกออกแบบมาให้นำไปใช้สร้าง object ไม่ใช่คลาสสำหรับนำไปทำเป็น base class แต่ถ้าท่านต้องการจะนำไปใช้เป็น base class เพื่อพัฒนาต่อยอด ก็สามารถทำได้เช่นกัน </span></p>
<p><span style="font-size:small;font-family:Courier New;"><a href="http://by1.storage.msn.com/y1p2A1sE9nJDcPdOJcOkiTTuwG5hfl-G27gWS7rSop2LXVgOc2Y1kNd4AHigliqFCZN8yIMYopYKOdl7nc49lgL3G6IoEQYN6--"><img src="http://by1.storage.msn.com/y1p2A1sE9nJDcOoaGox91_dc0VJlYFHiKIGpZgmwnsnM5IvCEKZjx3zy5BTptP5MwM3ymXvRgpxQv2WRtlJbESCjTnXRqhD--uu" alt="" width="309" height="416" /></a> </span></p>
<p><span style="font-size:small;font-family:Courier New;"><span style="color:#800000;">รูป 007คลาสไดอะแกรมของ TempReader จะเห็นว่าคลาสนี้มีสมาชิกหลายแบบ คือมีฟิลด์สมาชิกสามตัว property สมาชิกหนึ่งตัว method สมาชิกสี่ตัว และสมาชิกแบบ event หนึ่งตัว โปรดสังเกตว่า delegate มีภาวะเป็น nested type</span> </span></p>
<p><span style="font-size:small;font-family:Courier New;">โค้ดของคลาส TempReader ค่อนข้างสั้น เพราะเจตนาเขียนให้อ่านง่าย ไม่ซับซ้อน ซอร์สโค้ด เป็นดังที่เห็นข้างล่าง หากท่านไม่ต้องการป้อนพิมพ์ก็สามารถดาวน์โหลดมาทดสอบการทำงานได้จากเว็บไซต์ของผู้เขียน ( www.laploy.com/download ไฟล์ชื่อ TempReader.cs) </span></p>
<p>using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
using System.IO.Ports;<br />
using System.Threading;<br />
namespace Climsel<br />
{<br />
class TemppReader<br />
{<br />
public delegate void TemppReaderEventHandler(string tempp);<br />
public event TemppReaderEventHandler TemppReaderFire;<br />
private SerialPort myTemppComPort = new SerialPort();<br />
private int temppComPort;<br />
private string rxString;<br />
public int TemppComPort<br />
{<br />
get { return temppComPort; }<br />
set { temppComPort = value; }<br />
}<br />
public void GetTempp(string code)<br />
{<br />
if (!myTemppComPort.IsOpen) myTemppComPort.Open();<br />
myTemppComPort.Write(code);<br />
}<br />
public void CloseCom()<br />
{<br />
myTemppComPort.Close();<br />
}<br />
public void CreateTemppConnection()<br />
{<br />
myTemppComPort.Close();<br />
myTemppComPort.BaudRate = 9600;<br />
myTemppComPort.PortName = &#8220;COM&#8221; + temppComPort.ToString();<br />
myTemppComPort.Parity = Parity.None;<br />
myTemppComPort.DataBits = 8;<br />
myTemppComPort.StopBits = StopBits.One;<br />
myTemppComPort.RtsEnable = true;<br />
myTemppComPort.DataReceived += new SerialDataReceivedEventHandler(myTemppComPort_DataReceived);<br />
}<br />
private void myTemppComPort_DataReceived(object sender, SerialDataReceivedEventArgs e)<br />
{<br />
rxString += myTemppComPort.ReadExisting();<br />
if (rxString[rxString.Length-1] == &#8216;\r&#8217; )<br />
{<br />
TemppReaderFire(rxString);<br />
rxString = &#8220;&#8221;;<br />
}<br />
}<br />
}<br />
}</p>
<p><span></span></p>
<p>โค้ดส่วนบนสุดคือกลุ่มคำสั่ง using ทำหน้าที่จับรวม namespace ห้า namespace เข้ามาคอมไพล์ร่วมด้วย คำสั่ง using เป็นคำสั่งในภาษา C# ทำหน้าที่คล้ายๆ คำสั่ง include ในภาษาซี หรือภาษา PHP แตกต่างกันตรงที่คำสั่ง include ทำหน้าที่ผนวกฟังค์ชันจากไฟล์ที่เป็นซอร์สโค้ด ขณะที่คำสั่ง using ทำหน้าที่ผนวก type ภายใน namespace ที่อ้างถึง โดย type เหล่านั้นอยู่ในสภาพไฟล์แอสเซมบลี (คือไฟล์นามสกุล .dll ของ .NET Framework) ที่คอมไพล์ไว้แล้ว</p>
<p>สำหรับผู้ที่ใช้ภาษาจาวาและ VB.NET โปรดเข้าใจว่าคำสั่ง using ก็คือคำสั่ง import นั่นเอง คำสั่ง using ทั้งหมดถูกแทรกเข้ามาโดยอัตโนมัติโดยโปรแกรม Visual Studio .NET ยกเว้น using System.IO.Ports;<br />
ที่ผู้เขียนใส่เข้าไปเอง เพราะ namespace นี้เกี่ยวข้องโดยตรงกับการใช้งานพอร์ทอนุกรม</p>
<p>ถัดมาคำสั่ง namespace Laploy.TempHumReader ทำหน้าที่ประกาศ namespace ที่ผู้เขียนกำหนดขึ้นสำหรับโปรแกรมนี้ .NET Framework สนับสนุนให้เราตั้ง namespace ขึ้นเองเพื่อป้องกัน error ที่เกิดจากการตั้งชื่อ type ซ้ำกัน ซึ่งมีโอกาสเกิดขึ้นได้หากทำงานเป็นทีม หรือมีการนำ type ที่เคยนิยามไว้กลับมาใช้ใหม่</p>
<p>ต่อมาคำสั่ง class TemppReader ทำหน้าที่บอกจุดเริ่มต้นของนิยามคลาส โปรดสังเกตว่าผู้เขียนใช้วิธีตั้งชื่อคลาสแบบ ปาสคาล (pascal case) ซึ่งเป็นธรรมเนียมปฏิบัติของการตั้งชื่อคลาสในภาษา C#</p>
<p>การประกาศ Delegate และ Event</p>
<p>สองบรรทัดถัดมาคือการประกาศ delegate และ event โดยกำหนดให้ทั้งสองตัวมี access modifier เป็นแบบ public ทั้งคู่ เพราะเราต้องการให้คลาสที่จะใช้งาน object นี้ (คือโปรแกรมที่เรียกใช้งานคลาสนี้ ต่อไปจะเรียกว่า client class) สามารถเข้าถึงมันได้</p>
<p>ในคลาสนี้ผู้เขียนจะสาทิตการใช้ delegate เพื่อทำงานแบบ call back เพื่อให้ client class รับรู้การทำงานเมื่อพอร์ทอนุกรมได้รับข้อมูลจาก AP170 สำหรับนักเขียนภาษาซี และ C++ ขอให้เข้าใจว่านี่เป็นการทำงานเลียนแบบ function pointer แตกต่างจาก function pointer ตรงที่เป็นกลไกซึ่งมีคุณสมบัติ type safety โดยสมบูรณ์ (ไม่ต้องใช้ pointer)</p>
<p>คำสั่ง public delegate void TemppReaderEventHandler(string tempp); ทำหน้าที่ประกาศ delegate ชื่อ TemppReaderEventHandler โปรดสังเกตว่ารูปแบบการประกาศ delegate คล้ายการนิยามส่วนหัวของ method เพราะมีทั้ง return type, ชื่อ method และพารามิเตอร์ เราเรียกการประกาศเช่นนี้ว่า anonymous method เพราะเป็น method ที่เราไม่ได้นิยามไว้จริง รูปแบบเช่นนี้ช่วยอำนวยความสะดวกในการใช้งาน delegate (anonymous method เริ่มมีใช้ใน .NET 2.0)</p>
<p>บรรทัดถัดมา public event TemppReaderEventHandler TemppReaderFire; ทำหน้าที่ประกาศ event ที่เราต้องการให้ทำงานเมื่อพอร์ทอนุกรมได้รับข้อมูลจาก AP170 เมื่อเกิด event ขึ้น delegate จะทำงานโดยเรียก anonymous method ให้ทำงาน ถ้าอ่านถึงตรงนี้แล้วยังไม่เข้าใจก็ไม่เป็นไร เพระอีกสักครู่ เมื่อท่านเห็นส่วนใช้งาน anonymous method แล้วจะเข้าใจดีขึ้น</p>
<p>โปรดสังเกตว่าการประกาศ delegate เป็นการนิยาม type ใหม่ ในกรณีนี้เป็น type ที่ซ้อนอยู่ภายในคลาส TemppReader การประกาศเช่นนี้เรียกว่า nested type (ดูในคลาสไดอะแกรม)</p>
<p><strong>การประกาศฟิลด์สมาชิก</strong></p>
<p>ฟิลด์สมาชิกทำหน้าที่เก็บข้อมูลใน object ทำให้ object มีความเบ็ดเสร็จในตัวตามหลักการ encapsulation ในกรณีที่ไม่ใช่ static class (ตามในตัวอย่างนี้) object แต่ละตัวจะมีฟิลด์สมาชิกเป็นของตัวเอง ยกตัวอย่างเช่น หากเราสร้าง object สาม object จะเกิดฟิลด์สมาชิกสามชุด สำหรับแต่ละ object ไม่ปะปนกัน</p>
<p>คลาส TempReader มีการประกาศสมาชิกแบบฟิลด์สามตัว มีภาวะเป็น private ทั้งสามตัว สมาชิกแบบฟิลด์ที่เป็น private จะมีขอบเขตอยู่ภายใน object ที่จะถูกสร้างจากคลาสนี้เท่านั้น ไม่สามารถถูกอ่าน-เขียนจาก client class ได้ จึงมักถูกเรียกว่า instance filed หรือ object filed</p>
<p>ฟิลด์ชื่อ myTemppComPort เป็นตัวแปรแบบ reference type ทำหน้าที่ใช้อ้างอิง object ซึ่งมี type เป็น SerialPort อันเป็น type ที่เกิดจากคลาสชื่อเดียวกันใน namespace ชื่อ System.IO.Ports ที่เราจับรวมไว้ด้วยคำสั่ง using ดังที่อธิบายไปตอนต้น</p>
<p>เมื่อสร้าง object ซึ่งทำหน้าที่ควบคุมพอร์ทอนุกรมแล้ว การใช้งานพอร์ทอนุกรมต่อไปจะทำได้ง่ายมาก เพราะเราเพียงกำหนด property ต่างๆ ให้แก่ฟิลด์ myTemppComPort และเรียก method ต่างๆ ของมัน เพียงเท่านี้เราก็จะสามารถรับ-ส่งข้อมูลกับพอร์ทอนุกรมได้แล้ว ท่านจะได้เห็นตัวอย่างวิธีเรียกใช้ object นี้ในโค้ดส่วนทดสอบการใช้งานตอนท้ายของบทความ (คลาส test)</p>
<p>ถัดมาคือฟิลด์ชื่อ temppComPort ทำหน้าที่เก็บค่าหมายเลขพอร์ท ในเครื่องพีซีโดยทั่วไปจะมีพอร์ทอนุกรมสองพอร์ท ชื่อ COM1 และ COM2 เดิมที่เรามักใช้พอร์ท COM1 เพื่อต่อกับเมาส์ แต่ปัจจุบันเมาส์ส่วนใหญ่เป็นอินเตอร์เฟสแบบ USB หมดแล้ว พอร์ท COM1 และ COM2 จึงไม่ได้ใช้และถูกปล่อยทิ้งว่างไว้</p>
<p>ฟิลด์ตัวสุดท้ายชื่อ rxString ทำหน้าที่รับข้อมูลอุณหภูมิและความชื้นจาก AP170</p>
<p><strong>โปรดติดตามตอนจบ</strong></p>
<p>นิยามคลาส TempReader ยังไม่จบ แต่หน้ากระดาษหมดเสียก่อน ที่ท่านอ่านไปแล้วในตอนนี้เป็นเรื่องอุปกรณ์ที่เราต้องใช้เพื่อรับข้อมูลอุณหภูมิและความชื้น วิธีนำอุปกรณ์เหล่านี้มาต่อเชื่อมกันเป็นระบบ วิธีเขียนคำสั่งควบคุมอุปกรณ์ วิธีที่อุปกรณ์และคอมพิวเตอร์สื่อสารกัน และวิธีนิยามคลาส TempReader เพื่อห่อหุ้มอุปกรณ์และพอร์ทอนุกรมไว้เป็นก้อนเดียวกัน</p>
<p>ในตอนหน้าซึ่งเป็นตอนจบ เราจะมาดูนิยามส่วนที่เหลือของ คลาส TempReader ได้แก่ส่วนประกาศสมาชิกแบบ property ส่วนนิยาม method สมาชิก และดูตัวอย่างวิธีสร้าง object จากคลาส TempReader ซึ่งจะช่วยให้ท่านจะสามารถนำ object นี้ไปใช้งานในโครงงานต่างๆ ของท่านได้ทันที</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/on006.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/on006.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/on006.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/on006.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/on006.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/on006.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/on006.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/on006.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/on006.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/on006.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/on006.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/on006.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/on006.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/on006.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/on006.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/on006.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=on006.wordpress.com&amp;blog=4132251&amp;post=6&amp;subd=on006&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://on006.wordpress.com/2008/07/05/%e0%b8%a7%e0%b8%b1%e0%b8%94%e0%b8%ad%e0%b8%b8%e0%b8%93%e0%b8%ab%e0%b8%a0%e0%b8%b9%e0%b8%a1%e0%b8%b4%e0%b9%81%e0%b8%a5%e0%b8%b0%e0%b8%84%e0%b8%a7%e0%b8%b2%e0%b8%a1%e0%b8%8a%e0%b8%b7%e0%b9%89%e0%b8%99/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fd2f2b343fea71db0292fe37b17dcbd6?s=96&#38;d=identicon" medium="image">
			<media:title type="html">on006</media:title>
		</media:content>

		<media:content url="http://byfiles.storage.msn.com/y1pZRw2KH8yHQW5-mw3enY11y2KhfdInZXrbpSX9nZUOmUwAhpcVatoMY5lkpJOEjsYZrIAWdtsjYo" medium="image" />

		<media:content url="http://byfiles.storage.msn.com/y1pZRw2KH8yHQWSVchA0NUoZ9w7B0CoqIMFDpDAUW72rKsHCpCML2AgW3eDzUylaClcC8kSszvsG0I" medium="image" />

		<media:content url="http://byfiles.storage.msn.com/y1pZRw2KH8yHQUGYCAfnQI1ad59xkBPmSRxafj7B-lsIZ8Mo8dXF9K_v-OT4wQcEyeiaFmn_WBV8gc" medium="image" />

		<media:content url="http://byfiles.storage.msn.com/y1pZRw2KH8yHQXAmczdrartkBp2HVreMs_z3NrqJ9a23GCs0rnsQiQCV7IXgJWMFMqxIHhCZ_j5og8" medium="image" />

		<media:content url="http://by1.storage.msn.com/y1p2A1sE9nJDcM37CVC9s_RijaPV11--Iy4RbWP01F9cUMy56einM07DT592d6zBxXz4kNrpfBmmCO9vncxw2PheQ" medium="image" />

		<media:content url="http://by1.storage.msn.com/y1p2A1sE9nJDcPnXB43frhp60wY04_dBpXnV5t54WEeNXEG4X0iqEI64N4OxMfAsh6gVgCJ3zCimgyhX_jb4u1Zh4PF0yrVnfnu" medium="image" />

		<media:content url="http://by1.storage.msn.com/y1p2A1sE9nJDcOoaGox91_dc0VJlYFHiKIGpZgmwnsnM5IvCEKZjx3zy5BTptP5MwM3ymXvRgpxQv2WRtlJbESCjTnXRqhD--uu" medium="image" />
	</item>
		<item>
		<title>แต่งเก๋ๆ สไตล์ชินจูกุ</title>
		<link>http://on006.wordpress.com/2008/07/05/%e0%b9%81%e0%b8%95%e0%b9%88%e0%b8%87%e0%b9%80%e0%b8%81%e0%b9%8b%e0%b9%86-%e0%b8%aa%e0%b9%84%e0%b8%95%e0%b8%a5%e0%b9%8c%e0%b8%8a%e0%b8%b4%e0%b8%99%e0%b8%88%e0%b8%b9%e0%b8%81%e0%b8%b8/</link>
		<comments>http://on006.wordpress.com/2008/07/05/%e0%b9%81%e0%b8%95%e0%b9%88%e0%b8%87%e0%b9%80%e0%b8%81%e0%b9%8b%e0%b9%86-%e0%b8%aa%e0%b9%84%e0%b8%95%e0%b8%a5%e0%b9%8c%e0%b8%8a%e0%b8%b4%e0%b8%99%e0%b8%88%e0%b8%b9%e0%b8%81%e0%b8%b8/#comments</comments>
		<pubDate>Sat, 05 Jul 2008 20:28:38 +0000</pubDate>
		<dc:creator>on006</dc:creator>
				<category><![CDATA[แฟชั่น]]></category>
		<category><![CDATA[fashion]]></category>

		<guid isPermaLink="false">http://on006.wordpress.com/?p=5</guid>
		<description><![CDATA[ถ้าประเทศไทยมีย่านสยามสแควร์เป็นศูนย์กลางของคนทันสมัยแล้วล่ะก็ สำหรับในญี่ปุ่นคงหนีไม่พ้นย่านชินจูกุ แหล่งรวมคนรุ่นใหม่ มีคนรุ่นใหม่ แต่งตัวเก๋ ประโคมใส่เสื้อผ้ากันสุดฤทธิ์สุดเดช มาเดินขวักไขว่กันไม่เว้นแต่ละวัน ชินกูจุจึงเป็นศูนย์กลางแห่งความเป็นตัวของตัวเองที่แสดงออกกันอย่างสร้างสรรค์ จนกลายไอคอนของญี่ปุ่นร่วมสมัยไปเรียบร้อยแล้ว สำหรับหนุ่มสาวไทยที่ชื่นชอบการแต่งกายในสไตล์ญี่ปุ่น วีว่า แบงค็อก ฉบับนี้ มีไอเดียการแต่งตัวเก๋ๆ สไตล์ชินจูกุมานำเสนอเป็นแรงบันดาลใจ Color สาวญี่ปุ่นสมัยใหม่กล้าที่จะทดลองใช้สีแรงๆ และลวดลายแปลกตามาผสมผสานในหนึ่งชุดได้อย่างไม่แคร์สายตาใคร Tips - ด้วยความที่สาวญี่ปุ่นมีพื้นเพเดิมเป็นคนผิวขาวมาก การเลือกสีสดแปร๋นมาสวมใส่มิใช่เรื่องน่าตกใจแต่อย่างใด แต่สำหรับสาวไทยที่มีความแรง ระดับไม่หวาดหวั่นต่อสายตาที่จับจ้องมองมา ลองแมทช์คู่สีตรงข้ามในหนึ่งชุดที่วางอยู่บนสีพื้นจะเซฟสุด - ในซีซั่นนี้ “ลาย” แปลกมาแรง ลองเลือกชิ้นที่มีลายสีสดตัดกันสุดขั้วแบบแนว expressionism จะทำให้เสื้อผ้าชุดนั้นเด่นจนคนต้องเหลียวมอง Form จะว่าไปรูปทรงที่สาวญี่ปุ่นนิยมใช้นั้น ไม่มีข้อกำหนดตายตัว เพราะสาวๆ แดนอาทิตย์อุทัยมักเปิดกว้างทางความคิดเป็นอย่างมาก พวกเธอพร้อมที่จะนำเอาแพทเทิร์นแบบตะวันตกสุดโต่งมาผสมผสานกับแพทเทิร์นแบบตะวันออกได้อย่างลงตัว Tips - หากอยากลองใส่เสื้อแพทเทิร์นแปลกๆ โปรดอย่าประโคมทั้งเสื้อและกางเกง ถ้าเสื้อเปรี้ยวปรี๊ด ขอให้เลือกใช้กางเกงเรียบๆ หรือถ้ากางเกง/ กระโปรงทรงพิสดารให้สวมกับเสื้อทีเชิ้ตเนื้อบางเบาสีอ่อน เพื่อให้ส่วนล่างสะดุดทุกสายตาที่มอง - แอคเซสซอรี่ก็เช่นกัน ควรมีเฉดสี วัตถุ หรือรูปทรงบางอย่างที่กลืนไปกับเสื้อ กางเกง หรือกระโปรง อย่าพยายามใช้สิ่งที่คอนทรานส์ชนิดสุดโต่ง [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=on006.wordpress.com&amp;blog=4132251&amp;post=5&amp;subd=on006&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="color:#ff00ff;"> ถ้าประเทศไทยมีย่านสยามสแควร์เป็นศูนย์กลางของคนทันสมัยแล้วล่ะก็ สำหรับในญี่ปุ่นคงหนีไม่พ้นย่านชินจูกุ แหล่งรวมคนรุ่นใหม่ มีคนรุ่นใหม่ แต่งตัวเก๋ ประโคมใส่เสื้อผ้ากันสุดฤทธิ์สุดเดช มาเดินขวักไขว่กันไม่เว้นแต่ละวัน ชินกูจุจึงเป็นศูนย์กลางแห่งความเป็นตัวของตัวเองที่แสดงออกกันอย่างสร้างสรรค์ จนกลายไอคอนของญี่ปุ่นร่วมสมัยไปเรียบร้อยแล้ว สำหรับหนุ่มสาวไทยที่ชื่นชอบการแต่งกายในสไตล์ญี่ปุ่น วีว่า แบงค็อก ฉบับนี้ มีไอเดียการแต่งตัวเก๋ๆ สไตล์ชินจูกุมานำเสนอเป็นแรงบันดาลใจ</span><span id="more-5"></span></p>
<div style="text-align:center;"><img class="aligncenter" src="http://www.udclick.com/home1/images/stories/Content2/fashion/fashion_trend/20080611trend0201.jpg" border="0" alt="Image" hspace="6" width="400" height="527" /></div>
<p><span style="color:#008000;"><strong> Color</strong><br />
สาวญี่ปุ่นสมัยใหม่กล้าที่จะทดลองใช้สีแรงๆ และลวดลายแปลกตามาผสมผสานในหนึ่งชุดได้อย่างไม่แคร์สายตาใคร</span></p>
<p><span style="color:#800000;"><strong> Tips</strong><br />
- ด้วยความที่สาวญี่ปุ่นมีพื้นเพเดิมเป็นคนผิวขาวมาก การเลือกสีสดแปร๋นมาสวมใส่มิใช่เรื่องน่าตกใจแต่อย่างใด แต่สำหรับสาวไทยที่มีความแรง<br />
ระดับไม่หวาดหวั่นต่อสายตาที่จับจ้องมองมา ลองแมทช์คู่สีตรงข้ามในหนึ่งชุดที่วางอยู่บนสีพื้นจะเซฟสุด</span></p>
<p><span style="color:#993366;">- ในซีซั่นนี้ “ลาย” แปลกมาแรง ลองเลือกชิ้นที่มีลายสีสดตัดกันสุดขั้วแบบแนว expressionism จะทำให้เสื้อผ้าชุดนั้นเด่นจนคนต้องเหลียวมอง</span></p>
<div style="text-align:center;"><img class="aligncenter" src="http://www.udclick.com/home1/images/stories/Content2/fashion/fashion_trend/20080611trend0202.jpg" border="0" alt="Image" hspace="6" width="400" height="527" /></div>
<p><span style="color:#3366ff;"><strong> Form</strong><br />
จะว่าไปรูปทรงที่สาวญี่ปุ่นนิยมใช้นั้น ไม่มีข้อกำหนดตายตัว เพราะสาวๆ แดนอาทิตย์อุทัยมักเปิดกว้างทางความคิดเป็นอย่างมาก พวกเธอพร้อมที่จะนำเอาแพทเทิร์นแบบตะวันตกสุดโต่งมาผสมผสานกับแพทเทิร์นแบบตะวันออกได้อย่างลงตัว</span></p>
<p><span style="color:#800080;"><strong> Tips</strong><br />
- หากอยากลองใส่เสื้อแพทเทิร์นแปลกๆ โปรดอย่าประโคมทั้งเสื้อและกางเกง ถ้าเสื้อเปรี้ยวปรี๊ด ขอให้เลือกใช้กางเกงเรียบๆ หรือถ้ากางเกง/<br />
กระโปรงทรงพิสดารให้สวมกับเสื้อทีเชิ้ตเนื้อบางเบาสีอ่อน เพื่อให้ส่วนล่างสะดุดทุกสายตาที่มอง</span></p>
<p><span style="color:#800080;">- แอคเซสซอรี่ก็เช่นกัน ควรมีเฉดสี วัตถุ หรือรูปทรงบางอย่างที่กลืนไปกับเสื้อ กางเกง หรือกระโปรง อย่าพยายามใช้สิ่งที่คอนทรานส์ชนิดสุดโต่ง เพราะอาจทำให้โดนตีความเกี่ยวกับตัวคุณแบบผิดๆ ได้</span></p>
<p><span style="color:#808080;"> ที่มาข้อมูล :นิตยสาร VIVA Bangkok</span></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/on006.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/on006.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/on006.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/on006.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/on006.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/on006.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/on006.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/on006.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/on006.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/on006.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/on006.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/on006.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/on006.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/on006.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/on006.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/on006.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=on006.wordpress.com&amp;blog=4132251&amp;post=5&amp;subd=on006&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://on006.wordpress.com/2008/07/05/%e0%b9%81%e0%b8%95%e0%b9%88%e0%b8%87%e0%b9%80%e0%b8%81%e0%b9%8b%e0%b9%86-%e0%b8%aa%e0%b9%84%e0%b8%95%e0%b8%a5%e0%b9%8c%e0%b8%8a%e0%b8%b4%e0%b8%99%e0%b8%88%e0%b8%b9%e0%b8%81%e0%b8%b8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fd2f2b343fea71db0292fe37b17dcbd6?s=96&#38;d=identicon" medium="image">
			<media:title type="html">on006</media:title>
		</media:content>

		<media:content url="http://www.udclick.com/home1/images/stories/Content2/fashion/fashion_trend/20080611trend0201.jpg" medium="image">
			<media:title type="html">Image</media:title>
		</media:content>

		<media:content url="http://www.udclick.com/home1/images/stories/Content2/fashion/fashion_trend/20080611trend0202.jpg" medium="image">
			<media:title type="html">Image</media:title>
		</media:content>
	</item>
		<item>
		<title>ประวัติความเป็นมาของภาษา PHP</title>
		<link>http://on006.wordpress.com/2008/07/03/php/</link>
		<comments>http://on006.wordpress.com/2008/07/03/php/#comments</comments>
		<pubDate>Thu, 03 Jul 2008 11:43:34 +0000</pubDate>
		<dc:creator>on006</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[        PHP เป็นภาษาจำพวก scripting language  คำสั่งต่างๆจะเก็บอยู่ในไฟล์ที่เรียกว่าสคริปต์ (script) และเวลาใช้งานต้องอาศัยตัวแปลชุดคำสั่ง ตัวอย่างของภาษาสคริปก็เช่น JavaScript, Perl เป็นต้น ลักษณะของ PHP ที่แตกต่างจากภาษาสคริปต์แบบอื่นๆ คือ PHP ได้รับการพัฒนาและออกแบบมา เพื่อใช้งานในการสร้างเอกสารแบบ HTML โดยสามารถ สอดแทรกหรือแก้ไขเนื้อหาได้โดยอัตโนมัติ ดังนั้นจึงกล่าวว่า PHP เป็นภาษาที่เรียกว่า server-side หรือ HTML-embedded scripting language เป็นเครื่องมือที่สำคัญชนิดหนึ่ง ที่ช่วยให้เราสามารถสร้างเอกสารแบบ Dynamic HTML ได้อย่างมีประสิทธิภาพและมีลูกเล่นมากขึ้น         ถ้าใครรู้จัก Server Side Include (SSI) ก็จะสามารถเข้าใจการทำงานของ PHP ได้ไม่ยาก สมมุติว่า เราต้องการจะแสดงวันเวลาปัจจุบันที่ผู้เข้ามาเยี่ยมชมเว็บไซด์ในขณะนั้น ในตำแหน่ง ใดตำแหน่งหนึ่งภายในเอกสาร HTML ที่เราต้องการ  อาจจะใช้คำสั่งในรูปแบบนี้ เช่น &#60;!&#8211;#exec cgi=&#8221;date.pl&#8221;&#8211;&#62; ไว้ในเอกสาร [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=on006.wordpress.com&amp;blog=4132251&amp;post=1&amp;subd=on006&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>        PHP เป็นภาษาจำพวก scripting language  คำสั่งต่างๆจะเก็บอยู่ในไฟล์ที่เรียกว่าสคริปต์ (script) และเวลาใช้งานต้องอาศัยตัวแปลชุดคำสั่ง ตัวอย่างของภาษาสคริปก็เช่น JavaScript, Perl เป็นต้น ลักษณะของ PHP ที่แตกต่างจากภาษาสคริปต์แบบอื่นๆ คือ PHP ได้รับการพัฒนาและออกแบบมา เพื่อใช้งานในการสร้างเอกสารแบบ HTML โดยสามารถ สอดแทรกหรือแก้ไขเนื้อหาได้โดยอัตโนมัติ ดังนั้นจึงกล่าวว่า PHP เป็นภาษาที่เรียกว่า server-side หรือ HTML-embedded scripting language เป็นเครื่องมือที่สำคัญชนิดหนึ่ง ที่ช่วยให้เราสามารถสร้างเอกสารแบบ Dynamic HTML ได้อย่างมีประสิทธิภาพและมีลูกเล่นมากขึ้น <span id="more-1"></span></p>
<p>        ถ้าใครรู้จัก Server Side Include (SSI) ก็จะสามารถเข้าใจการทำงานของ PHP ได้ไม่ยาก สมมุติว่า เราต้องการจะแสดงวันเวลาปัจจุบันที่ผู้เข้ามาเยี่ยมชมเว็บไซด์ในขณะนั้น ในตำแหน่ง ใดตำแหน่งหนึ่งภายในเอกสาร HTML ที่เราต้องการ  อาจจะใช้คำสั่งในรูปแบบนี้ เช่น &lt;!&#8211;#exec cgi=&#8221;date.pl&#8221;&#8211;&gt; ไว้ในเอกสาร HTML เมื่อ SSI ของ web server มาพบคำสั่งนี้ ก็จะกระทำคำสั่ง date.pl ซึ่งในกรณีนิ้ เป็นสคริปต์ที่เขียนด้วยภาษา perl สำหรับอ่านเวลาจากเครื่องคอมพิวเตอร์ แล้วใส่ค่าเวลาเป็นเอาพุท (output) และแทนที่คำสั่งดังกล่าว ลงในเอกสาร HTML โดยอัตโนมัติ ก่อนที่จะส่งไปยังผู้อ่านอีกทีหนึ่ง</p>
<p>        อาจจะกล่าวได้ว่า PHP ได้รับการพัฒนาขึ้นมา เพื่อแทนที่ SSI รูปแบบเดิมๆ โดยให้มีความสามารถ และมีส่วนเชื่อมต่อกับเครื่องมือชนิดอื่นมากขึ้น เช่น ติดต่อกับคลังข้อมูลหรือ database เป็นต้น</p>
<p>        PHP ได้รับการเผยแพร่เป็นครั้งแรกในปีค.ศ.1994 จากนั้นก็มีการพัฒนาต่อมาตามลำดับ เป็นเวอร์ชั่น 1 ในปี 1995 เวอร์ชั่น 2 (ตอนนั้นใช้ชื่อว่า PHP/FI) ในช่วงระหว่าง 1995-1997 และเวอร์ชั่น 3 ช่วง 1997 ถึง 1999 จนถึงเวอร์ชั่น 4 ในปัจจุบัน</p>
<p>        PHP เป็นผลงานที่เติบโตมาจากกลุ่มของนักพัฒนาในเชิงเปิดเผยรหัสต้นฉบับ หรือ OpenSource ดังนั้น PHP จึงมีการพัฒนาไปอย่างรวดเร็ว และแพร่หลายโดยเฉพาะอย่างยิ่งเมื่อใช้ร่วมกับ Apache Webserver ระบบปฏิบัติอย่างเช่น Linux หรือ FreeBSD เป็นต้น ในปัจจุบัน PHP สามารถใช้ร่วมกับ Web Server หลายๆตัวบนระบบปฏิบัติการอย่างเช่น Windows 95/98/NT เป็นต้น</p>
<p><span style="color:#800080;">รายชื่อของนักพัฒนาภาษา PHP ที่เป็นแก่นสำคัญในปัจจุบันมีดังต่อไปนี้</span></p>
<ul>
<li><span style="color:#800080;">Zeev Suraski, Israel</span></li>
<li><span style="color:#800080;">Andi Gutmans, Israel</span></li>
<li><span style="color:#800080;">Shane Caraveo, Florida USA</span></li>
<li><span style="color:#800080;">Stig Bakken, Norway</span></li>
<li><span style="color:#800080;">Andrey Zmievski, Nebraska USA</span></li>
<li><span style="color:#800080;">Sascha Schumann, Dortmund, Germany</span></li>
<li><span style="color:#800080;">Thies C. Arntzen, Hamburg, Germany</span></li>
<li><span style="color:#800080;">Jim Winstead, Los Angeles, USA</span></li>
<li><span style="color:#800080;">Rasmus Lerdorf, North Carolina, USA</span></li>
</ul>
<p>        เนื่องจากว่า PHP ไม่ได้เป็นส่วนหนึ่งของตัว Web Server ดังนั้นถ้าจะใช้ PHP ก็จะต้องดูก่อนว่า Web server นั้นสามารถใช้สคริปต์ PHP ได้หรือไม่ ยกตัวอย่างเช่น PHP สามารถใช้ได้กับ Apache WebServer และ Personal Web Server (PWP) สำหรับระบบปฏิบัติการ Windows 95/98/NT</p>
<p>        ในกรณีของ Apache เราสามารถใช้ PHP ได้สองรูปแบบคือ ในลักษณะของ CGI และ Apache Module  ความแตกต่างอยู่ตรงที่ว่า ถ้าใช้ PHP เป็นแบบโมดูล PHP จะเป็นส่วนหนึ่งของ Apache หรือเป็นส่วนขยายในการทำงานนั่นเอง ซึ่งจะทำงานได้เร็วกว่าแบบที่เป็น CGI เพราะว่า ถ้าเป็น CGI แล้ว ตัวแปลชุดคำสั่งของ PHP ถือว่าเป็นแค่โปรแกรมภายนอก ซึ่ง Apache จะต้องเรียกขึ้นมาทำงานทุกครั้ง ที่ต้องการใช้ PHP ดังนั้น ถ้ามองในเรื่องของประสิทธิ ภาพในการทำงาน การใช้ PHP แบบที่เป็นโมดูลหนึ่งของ Apache จะทำงานได้มีประสิทธิภาพมากกว่า</p>
<p>ต่อไปเราจะมาทำความรู้จักกับภาษา PHP และทำความเข้าใจการทำงาน รวมถึงคำสั่งพื้นฐานต่าง ๆ</p>
<p> </p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/on006.wordpress.com/1/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/on006.wordpress.com/1/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/on006.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/on006.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/on006.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/on006.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/on006.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/on006.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/on006.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/on006.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/on006.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/on006.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/on006.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/on006.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/on006.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/on006.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=on006.wordpress.com&amp;blog=4132251&amp;post=1&amp;subd=on006&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://on006.wordpress.com/2008/07/03/php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fd2f2b343fea71db0292fe37b17dcbd6?s=96&#38;d=identicon" medium="image">
			<media:title type="html">on006</media:title>
		</media:content>
	</item>
	</channel>
</rss>
