954,529 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?

GoTo Statement

0
By Endre Bende on Mar 8th, 2009 1:26 pm

Many people says 'Don't use the GoTo statement,because your code will be unreadable....'.I say,can be use

(*For those who now get on the train,'cause there are beginers always..*)
Program GoToExample;
Uses Crt;
Label here,there;
Var  ch:Char; {from ASCII}
Begin
     here:WriteLn('1,You''re here');
     WriteLn('Where are you going?');
     WriteLn('Press ''1'' for here,press ''2'' for there.: ');
     Ch:=ReadKey;{catch the answer}
     Case (Ch) Of    {analize it}
          #49:GoTo here;        {jump up}
          #50:GoTo there        {go down}
     Else Begin
               WriteLn('Wrong answer!');{if no matches then jump up}
               GoTo here;
          End;
     End;

     there:WriteLn('2,You''re there');
     ReadKey;
End.
(*
Release Note:
#49=1 button
#50=2 button from the keyboard
When asked 'Where are you going?',you'll press 1 or 2 button.
The choice is yours:If press 1 button then the program go up to the
label named 'here'.But if you press 2 button then the program jump down
to the 'there' label and the program will end*)

Here,there and everywhere...all over the place, start a course on cooking spagetti. Stop programming if you want to continue on this way, else try to use a while loop.

ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
 

Ok,I understand you 'ddanbe'....but there are times when you want to know many things about your favorit language (pascal)
and there are things that you can write but not really understand.
When I found this page,I thought :I find the right place,many language,nice works....but the pascal snippet was very gappy....
From that time,I'll try to write mini programs that demonstrate an solution,that helps beginners to understand.....and what about you?Why don't write you too?...The answer is that:'cause...
I know that the 'GoTo' command is not a good choice to create good program,but thereform the 'GoTo' is exists.....and the part of the Pascal language since 1973.

FlamingClaw
Posting Pro
559 posts since Feb 2009
Reputation Points: 132
Solved Threads: 138
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You