User Tools

Site Tools


tutorial:conditionalstatement

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tutorial:conditionalstatement [2019/01/07 11:16]
admin [Break, Continue, Exit and Goto]
tutorial:conditionalstatement [2019/01/07 13:00] (current)
admin [Break, Continue, Exit and Goto]
Line 161: Line 161:
 </​sxh>​ | </​sxh>​ |
 |Exit| ออกจาก Sub-Program ปัจจุบัน (Procedure/​Function) |<sxh delphi;> |Exit| ออกจาก Sub-Program ปัจจุบัน (Procedure/​Function) |<sxh delphi;>
-procedure ​ProcedureName;+procedure ​MyProc;
 begin begin
-  ​{Do something}+  ​exit; 
 +  writeln('​After Exit'​);​ //This won't be shown
 end; end;
 </​sxh>​ | </​sxh>​ |
-|Goto| ไปยัง Label ที่กำหนด ​|<sxh delphi;> +|Goto| ไปยัง Label ที่ระบุ ​|<sxh delphi;>​ 
-PROGRAM Test_Goto;​ +label PointA,PointB//declare labels
-var Answer:​Char;​ +
-label RightWay,​LeftWay,WrongWay;+
 BEGIN BEGIN
-write('​Please select your way: R/​L'​);​ + ​Goto ​PointB
-readln(Answer);​ + PointA
-if Answer='​R'​ then  + wrtieln('Passing PointA'); 
-  Goto RightWay + ​exit; ​//Exit the program 
-else if Answer='​L'​ then  + PointB
-  Goto LeftWay + wrtieln('Passing PointB'); 
-else  + Goto PointA;
-  ​Goto ​WrongWay+
- +
-RighWay+
-  ​writeln('you have selected Right Way'); +
-  exit; +
-LeftWay+
-  ​writeln('you have selected Left Way'); +
-  ​exit;​ +
-WrongWay: +
-  writeln('​you have selected wrong Way'​);​ +
-  exit;+
 END. END.
 </​sxh>​ | </​sxh>​ |
tutorial/conditionalstatement.1546834565.txt.gz · Last modified: 2019/01/07 11:16 by admin