This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
tutorial:proceduraltype [2018/09/21 10:50] admin |
tutorial:proceduraltype [2018/10/28 12:32] (current) admin |
||
|---|---|---|---|
| Line 105: | Line 105: | ||
| ---- | ---- | ||
| - | ====Function of Object==== | + | =====Function of Object===== |
| ตัวอย่างข้างบนนั้น ใช้ได้กับกรณีที่ function ถูกประกาศเป็น Global Scope เท่านั้น (จะสังเกตว่า func ไม่ได้อยู่ภายใต้ Class หรือ Object ใดๆ) ในกรณีที่ function ถูกประกาศเป็น Local Scope ภายใต้ Class หรือ Object ใดๆ จะต้องเปลี่ยนการประกาศ Type ใหม่เป็นดังนี้ | ตัวอย่างข้างบนนั้น ใช้ได้กับกรณีที่ function ถูกประกาศเป็น Global Scope เท่านั้น (จะสังเกตว่า func ไม่ได้อยู่ภายใต้ Class หรือ Object ใดๆ) ในกรณีที่ function ถูกประกาศเป็น Local Scope ภายใต้ Class หรือ Object ใดๆ จะต้องเปลี่ยนการประกาศ Type ใหม่เป็นดังนี้ | ||
| + | |||
| + | Type | ||
| + | TFunc = function(x:real):real of Object ; | ||
| <hidden Example-3: Function of Object (TForm)> | <hidden Example-3: Function of Object (TForm)> | ||
| Line 176: | Line 179: | ||
| </hidden> | </hidden> | ||
| ---- | ---- | ||
| + | =====Function is Nested===== | ||
| + | สำหรับการทำ Nested Function ให้กลายเป็น Procedural Type เพื่อส่งผ่านเป็นตัวแปรนั้น เราสามารถระบุ Function ดังกล่าวได้ตามนี้ | ||
| + | Type | ||
| + | TFunc = function(x:real):real is Nested ; | ||
| + | จะสังเกตได้ว่าคล้ายกับการระบุ Function of Object นั่นเอง เพียงแต่เปลี่ยนจากคำว่า of Object เป็น is Nested แต่อย่างไรก็ตามสิ่งที่แตกต่างกันอีกอย่างหนึ่ง คือ คำสั่งข้างต้น จำเป็นต้องระบุ Compiler Directive ดังนี้ก่อนเสมอ | ||
| + | |||
| + | {$modeswitch nestedprocvars} | ||
| + | | ||
| + | | ||