Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Break,Goto,label,...
12-23-2009, 08:53 PM
Post: #1
Question Break,Goto,label,...
Hi guys,Please help meConfused!I'm in the middle of a program,i want to know how can i return to previous loop that i want,for example:
Code:
Program 33333;
  Var
    i,j,k:integer;
Begin
  For i:=1 To 100 Do
    Begin
      For j:=1 To 100 Do
        Begin
          For k:=1 to 100 Do
            If {Something!...} Then
               {Here I want to go to the second For(with j counter)}
            Else
            .
            .
            .
What should I do?
P.S:I have read goto , break, label ,... instructions in Pascal's help but there was no advancement.
Thanks

Gholamreza Takhti
who was he? find out
Find all posts by this user
Quote this message in a reply
12-24-2009, 02:56 AM (This post was last modified: 12-24-2009 03:10 AM by drdebcol.)
Post: #2
RE: Break,Goto,label,...
I think that you need to go stop k loop, and that is by using "exit" command. So
the code should look like :
Code:
if condition then
exit;
Or by using go to and label.
You first declare label :
Code:
var
  label loop_j;
and then you make it in loop j like "loopj:"
and after condition, you just call it with go to :
Code:
if condition then
  goto loop_j;

"I dont know with what weapons World War 3 will be fought with, but i know World War 4 will be fought with stones and sticks" - Albert Einstein
Visit this user's website Find all posts by this user
Quote this message in a reply
12-24-2009, 06:03 AM
Post: #3
RE: Break,Goto,label,...
(12-24-2009 02:56 AM)drdebcol Wrote:  I think that you need to go stop k loop, and that is by using "exit" command. So
the code should look like :
Code:
if condition then
exit;
Or by using go to and label.
You first declare label :
Code:
var
  label loop_j;
and then you make it in loop j like "loopj:"
and after condition, you just call it with go to :
Code:
if condition then
  goto loop_j;
Thanks Wink

Gholamreza Takhti
who was he? find out
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


 Quick Theme: