Board index » delphi » How to manage GOTO's ??

How to manage GOTO's ??

Quote
In article <472hhj$...@news.bt.net> p...@tref.nl "Paul Rensel" writes:
> Hi all,

> I've the following problem:

> I have about 200 BASIC source files, which i would like to convert to
> Pascal.

> In these basic source files each line consists of one basic command
> followed by its parameters.
> some lines are multi-statement but that's no problem cause i can split
> them up.

> The only problem is, those GOTO's..

Oh dear.  You didn't use GOTOs did you?  tut tut.

You should rewrite your program to use repeats, whiles, breaks (if you have
a recentish version) and esp. functions and procedures.

--
Tom Wheeley, <holyhorns>
* TQ 1.0 * From the rec.humor.funny one-liner file.
Q: What do you have if you have two little, green balls in your hand??
A: Complete control of a leprechaun

 

Re:How to manage GOTO's ??


Quote
In article <472hhj$...@news.bt.net>, p...@tref.nl (Paul Rensel) writes:
>Hi all,

>I've the following problem:

>I have about 200 BASIC source files, which i would like to convert to
>Pascal.

>In these basic source files each line consists of one basic command
>followed by its parameters.
>some lines are multi-statement but that's no problem cause i can split
>them up.

>The only problem is, those GOTO's..

>I have been thinking about how to manage these
>so i get a structured program which i can convert to pascal.

>Somebody got an idea for this, or is it manually the only way ??

I used to have a utility that would reformat old GOTO and Line number
BASIC code into a "structured" basic that would work in Turbo or Quick
Basic; this should be a lot easier to translate into Pascal.  If memory
serves, it unrolled simpler GOTO constructs into more structured forms.

I just went out and found it on Oakland's FTP site.  Check out
oak.oakland.edu/SimTel/msdos/basic/basic2sb.zip

Quote
>thanks

>Paul
>p...@dpr.nl

Regards,

-* Stephen *-
Stephen Posey
University of New Orleans
Email  : S...@uno.edu
WWW    : http://www.uno.edu/~slp

Re:How to manage GOTO's ??


In article n...@news.tamu.edu, s0h7...@cs.tamu.edu (Salman Halim) writes:

Quote
> loop
>   .
>   .
>   something something break;
>   .
>   .
> end loop;

Oh ! This syntax sounds like ADA >:-[

The pascal syntax would rather look like :

While True do
begin
  .
  .
  something something break;
  .
  .
end;

or

repeat
  .
  .
  something something break;
  .
  .
until false;

Sorry  :-)

Bye,

Christophe.

Re:How to manage GOTO's ??


In article <47968r$...@spectator.cris.com> "Jerry L. Gubka" <jlg...@cris.com> writes:
[cut]

Quote
> Using this procedure
>with Fortran, I reduced the number of goto's in the original from about
>200 to 5-6.

[cut]

Only 200 GOTOs in a Fortran program. I guess you were lucky.

Fortunately with Pascal one can almost eliminate GOTOs. I say "almost" because
I have still used them occasionally in BP7 (handling errors) to avoid too
great a depth of nested  blocks that would make the code unreadable. With BP8
(or Delphi if you prefer) the exception handling and especially the "finally"
block makes even this use unnecessary.

Re:How to manage GOTO's ??


Quote
s0h7...@cs.tamu.edu (Salman Halim) wrote:
>>Oh dear.  You didn't use GOTOs did you?  tut tut.

>>You should rewrite your program to use repeats, whiles, breaks (if you have
>>a recentish version) and esp. functions and procedures.
>personally, i've always found a break to be implementable with the use of a
>goto -- what i'm saying is, i don't think it's any better than a goto:
>loop
>  .
>  .
>  something something break;
>  .
>  .
>end loop;
>{comes out here after break}
>this is the same thing as:
>loop
>  .
>  .
>  something something goto next_thing;
>  .
>  .
>end loop;
>next_thing:
>{comes out here after goto}
>it's just a different name for the same thing *shrug* it's an unconditional
>transfer of control, and it does away with the sanctity of the structure out of
>which you're breaking. . .
>mind you, i'm not saying that you should use breaks instead of gotos.  i just
>think the two things are, at least 90% of the time, conceptually identical.
>while the break DOES do away with the hassles of declaring and using a label,
>it's functionally the same.
>i think that if you don't want to execute a bunch of statements, you should
>skip over them by logic, without disrupting the sequential flow of a program,
>rather than by brute force. . .

If all Goto users limited themselves to the samples that you suggested
then I would agree with you, but the problem with GOTO is that it can
go anywhere (within the block), backward or forward, and you have to
look up where it goes.  BREAK on the otherhand ALWAYS breaks out of
the loop and starts execution at the NEXT statement, no ambiguity
there.

my 22 1/3 cents worth (adjusted for 1996 inflation).

Brad

Re:How to manage GOTO's ??


In article <47o8er$...@its.hooked.net>,
Leicester B. Ford Jr. <fb...@hooked.net> wrote:

Quote
>If all Goto users limited themselves to the samples that you suggested
>then I would agree with you, but the problem with GOTO is that it can
>go anywhere (within the block), backward or forward, and you have to
>look up where it goes.  BREAK on the otherhand ALWAYS breaks out of
>the loop and starts execution at the NEXT statement, no ambiguity
>there.

i think i could change most programs with gotos to ones that DIDN'T use gotos
-- i just don't think it's a necessary tool *shrug* -- mind you, i'm not saying
that all loops should be while loops (eg. for loops) so please don't
extrapolate here :)

just hand me a program with gotos and i'll muck it about -- i may not enjoy it
-- heck, i might not even relish it -- but when i'm done, hopefully it'll be
better structured.

my 2p worth,

salman.

Other Threads