Page 1 of 1

Replace Goto

Posted: Thu Feb 26, 2015 2:56 am
by johnno56
I have a bunch of old basic listings (line numbers) and I am trying to change them to a "more structured" look. (without line numbers)

Are there any tutorials on how to replace "goto" statements? Gosub's I can replace with "sub" routines. But the way most old listings are written, the goto's, are jumping all around the listing causing me no end of confusion. Also, in most cases, the "on goto's" can be a headache. I am not asking anyone to re-write them, otherwise I do not learn as much, I just need to know if there are any tips, tutorials, subroutines, that can be used to replace "goto"

Any information would be greatly appreciated.

J

Re: Replace Goto

Posted: Thu Feb 26, 2015 6:11 pm
by burger2227
GOTO is tough to redo, that's why we don't recommend it anymore to anyone, especially beginners.

Spaghetti code is very hard to fix so use loops instead where you can find them. GOTO is a last resort!

There are programs to get rid of line numbers, except where actually needed that may make it less confusing.

Re: Replace Goto

Posted: Fri Feb 27, 2015 4:33 am
by johnno56
I figured that you would respond like that... *sigh* I too find spaghetti code difficult, especially when to goto's jump all over the place, and try use loops and subs and functions where I can. There are a lot of old games and programs that were quite good in their day, and I figured that I could try and resurrect some of them, using current methods. Then the 'goto's' throw a spanner in the works... I was hoping that someone may have developed a method of converting early basic to a more structured basic. I though it might be a bit of a big request, but I figured I would ask anyway.

Looks like I may need a bigger supply of pen and paper and coffee...

Thank you for replying so quickly.

Regards

J

Re: Replace Goto

Posted: Fri Feb 27, 2015 8:30 am
by burger2227
Use this program to remove unecessary line numbers and it will make your job a lot easier: http://www.qb64.net/wiki/index.php/Line_number

There is also a link to a Microsoft program called remline.

Re: Replace Goto

Posted: Sat Feb 28, 2015 8:17 am
by johnno56
Ok. Very cool indeed. That little gem will save heaps of time. Much appreciated.

On a side note:

I have found a published basic listing called 'Haunted House", which is a simple 64 location 'text adventure', that I am trying to convert it using only loops and subs. It has line numbers, but I cannot use your program, as the listing is a pdf. If I get it finished, and I can get it to run, would you be able to give it a "look over" to see where improvements can be made? ( Cool. A conditional If...then statement. )

ps: Do not hold your breath waiting. My skills are not that good...

Regards

J