Board index » delphi » GOTO Command In Pascal "Need Help"

GOTO Command In Pascal "Need Help"

Yo,
Im just gettin into Programming with Pascal and I cant get the GOTO
commands to
work, Im using Turbo Pascal 6.0 For dos Can anyone help with detailed
instructions
im at bhar...@shoal.net.au
Thankz Brendon...
 

Re:GOTO Command In Pascal "Need Help"


Quote
>Im just gettin into Programming with Pascal and I cant get the GOTO
>commands

hello
at first try to don't use goto in your program
look at label in the help
bye
patrick
marseille

Re:GOTO Command In Pascal "Need Help"


In article <01bde556$396af160$842c1acb@bharris>, Brendon Harris
<bhar...@shoal.net.au> writes

Quote
>Yo,
>Im just gettin into Programming with Pascal and I cant get the GOTO
>commands to
>work, Im using Turbo Pascal 6.0 For dos Can anyone help with detailed
>instructions
>im at bhar...@shoal.net.au

Just avoid using it. It seems a terrible imposition when you first start
but, believe me, it is well worth it. After a relatively small time you
will forget it ever existed and your code will be vastly improved as a
result. One of the MAJOR reasons for writing in pascal is that the code
is clear, logical and largely free of silly, hard-to-spot, bugs (to
first order anyway). Using GOTO is a good way to produce unclear,
illogical code liberally sprinkled with silly, hard-to-spot, bugs.

--
Oz

Re:GOTO Command In Pascal "Need Help"


In article <01bde556$396af160$842c1acb@bharris>,

Quote
Brendon Harris <bhar...@shoal.net.au> wrote:
>Yo,
>Im just gettin into Programming with Pascal and I cant get the GOTO
>commands to
>work, Im using Turbo Pascal 6.0 For dos Can anyone help with detailed
>instructions
>im at bhar...@shoal.net.au
>Thankz Brendon...

I could tell you how to use but I won't. If you are a beginner in Pascal
then you should not use GOTO at all. There are places when GOTO can be
useful but you should not really even think about them before you master
constructing structures with while and repeat until and by making
procedures and functions.

Osmo

Re:GOTO Command In Pascal "Need Help"


Quote
"Brendon Harris" <bhar...@shoal.net.au> wrote:
>Yo,
>Im just gettin into Programming with Pascal and I cant get the GOTO
>commands to
>work, Im using Turbo Pascal 6.0 For dos Can anyone help with detailed
>instructions
>im at bhar...@shoal.net.au
>Thankz Brendon...

As a general rule, GOTO's should be avoided BUT there are times when logic
complexity is GREATLY reduced and readability is enhanced by the choice of
suitable labels for the GOTO. Try to avoid using more than one or two in
the entire program.

An example of no loss of clarity and simpler logic is to use the label
"finis" where there are multiple places in the main body to exit the
program but where some additional action such as closing files, etc. is
required.

Program Whatever;
Label finis;
....
Begin
....
If Length(source) = 0 then GOTO finis;
..... action
If not ok then GOTO finis;
.... action
If denom = 0 then GOTO finis;
.... final action and other tasks

finis:
{whatever closing conditions desired}
End.

Re:GOTO Command In Pascal "Need Help"


Very true. I have often used goto to get to an error checking portion of a
program.
Quote
Clif Penn wrote:
> "Brendon Harris" <bhar...@shoal.net.au> wrote:

> >Yo,
> >Im just gettin into Programming with Pascal and I cant get the GOTO
> >commands to
> >work, Im using Turbo Pascal 6.0 For dos Can anyone help with detailed
> >instructions
> >im at bhar...@shoal.net.au
> >Thankz Brendon...

> As a general rule, GOTO's should be avoided BUT there are times when logic
> complexity is GREATLY reduced and readability is enhanced by the choice of
> suitable labels for the GOTO. Try to avoid using more than one or two in
> the entire program.

> An example of no loss of clarity and simpler logic is to use the label
> "finis" where there are multiple places in the main body to exit the
> program but where some additional action such as closing files, etc. is
> required.

> Program Whatever;
> Label finis;
> ....
> Begin
> ....
> If Length(source) = 0 then GOTO finis;
> ..... action
> If not ok then GOTO finis;
> .... action
> If denom = 0 then GOTO finis;
> .... final action and other tasks

> finis:
> {whatever closing conditions desired}
> End.

Re:GOTO Command In Pascal "Need Help"


JRS:  In article <B11487BD823936D7.018856B77A413E6C.620F60FC8EA2217C@lib
rary-proxy.airnews.net> of Mon, 21 Sep 1998 20:46:46 in
comp.lang.pascal.borland, Clif Penn <clifp...@airmail.net> wrote:

Quote
> ...

>Program Whatever;
>Label finis;
>....
>Begin
>....
>If Length(source) = 0 then GOTO finis;
>..... action
>If not ok then GOTO finis;
>.... action
>If denom = 0 then GOTO finis;
>.... final action and other tasks

>finis:
>{whatever closing conditions desired}
>End.

While it's pretty acceptable to do that, with one clear self-descriptive
label, one can also do :

Program Whatever;
....
procedure Job ;
Begin
....
If Length(source) = 0 then EXIT;
..... action
If not ok then EXIT;
.... action
If denom = 0 then EXIT;
.... final action and other tasks
end {Job} ;

Begin
Job ;
{whatever closing conditions desired}
End.

--
John Stockton, Surrey, UK.    j...@merlyn.demon.co.uk    Turnpike v1.12    MIME.
  Web <URL: http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.

Other Threads