# Do you use goto???



## MrSeanKon (May 21, 2007)

Vote and discuss of course.
Sometimes it is necessary IMHO.


----------



## Deleted member 3 (May 21, 2007)

Hell yes, I had a teacher who went mental every time I used goto, kept telling me how bad it is and all. Quite a good motivation to use it. On the other hand, I hardly ever program anything, and when I do it's something really small and simple. I'd say goto works great in simple things.


----------



## MrSeanKon (May 21, 2007)

DanTheBanjoman do you program in Fortran??
If yes it is common the goto usage.


----------



## Deleted member 3 (May 21, 2007)

MrSeanKon said:


> DanTheBanjoman do you program in Fortran??
> If yes it is common the goto usage.



Never touched it.


----------



## Kreij (May 24, 2007)

I thought that goto statements were outlawed in the Geneva Convention  
They were considered too much like torture for the code maintainers.

I have not used a goto in about 20 years.


----------



## pt (May 24, 2007)

missed an option for vote
- wtf is goto?


----------



## Kreij (May 24, 2007)

pt said:


> missed an option for vote
> - wtf is goto?



In certain programming languages you can label a line of code by line number or a label and send the program execution to that line under specific instances.

Such as ...

1000 do something cool
1001 if results are not really cool GOTO 1000
1002 that was really cool

Bad example, but you get the drift.


----------



## PVTCaboose1337 (May 24, 2007)

I have used it in actionscript

gotoandplay(1);

that plays frame 1 of the scene


----------



## aximbigfan (May 24, 2007)

sure, why not?


chris


----------



## W1zzard (May 24, 2007)

yes i use it i in c/c++. sometimes miss having it in php. but i use it rarely only when it makes sense


----------



## mikek75 (May 24, 2007)

Ah, at last, a piece of this thread I understand from my ZX81 days...Who can forget the simple pleasure of typing in the local electrical shop:

10 PRINT " You are a wanker "
20 GOTO 10

Happy days...


----------



## gamer210 (May 24, 2007)

Aside from some programming in MIPS, I don't think I've ever used goto.


----------



## Deleted member 3 (May 24, 2007)

pt said:


> missed an option for vote
> - wtf is goto?



If you used it you knew what is was. Therefor you don't use it. ie your answer is there, it's "no"



Also, goto doesn't have to apply to linenumber, and even cmd.exe understands it
batchfile:


> :start
> net send 192.168.0.8 Hello world
> goto start



192.168.0.8 is W1zzards IP and he runs the messenger service. Just in case you wish to complain about it being disabled by default nowadays.


----------



## Zero Cool (May 24, 2007)

isnt that his internal IP adress? the one within the network?


----------



## zekrahminator (May 24, 2007)

pt said:


> missed an option for vote
> - wtf is goto?



Option added .


----------



## Zero Cool (May 25, 2007)

oh I forgot I use it in school sometimes
eg.
goto.hell()


----------



## Grings (May 25, 2007)

i remember using goto programming my spectrum, but i havent used it this century


----------



## aximbigfan (May 25, 2007)

Zero Cool said:


> oh I forgot I use it in school sometimes
> eg.
> goto.hell()



wait, isnt that javascript? i didnt know that js had a goto function...


chris


----------



## Zeratul_uy (May 25, 2007)

What is it for?


----------



## aximbigfan (May 25, 2007)

Zeratul_uy said:


> What is it for?



goto is a fucntion thart when runs, goes to a certain area of code. for example:

MSDOS

+
@echo off
:1
echo HELLO WORLD!
goto 1
+
this would produce an infinate loop of the script printing "HELLO WORLD".

it is more often used in a situation liek this:

in this example we assume that error level 0 means that the source fiel is missing, error level 1 means that the file was sucsefully copyied.

+
@echo off
echo please wait, copying...
xcopy hello.txt /dest/
if errorlevel = 0 goto 0 (yes, i prolly got this wrong, it been a long time)
if errorlevel = 1 goto 1 (yes, i prolly got this wrong, it been a long time)
:0
echo ERROR! file not found.
goto ge
:1
echo file copy sucsesful!
goto ge
:ge
exit?
pause
+

in the above example, ifthe file is missing, then it issues an error, then jumps to a gobal exit function, if it was sucsesful, it issues a the message, and goes to the global exit fuinction.

now, i know i prolly got parts of the batch code wrong, it has been a very long time since i activly coded in batch.


chris


----------



## Deleted member 3 (May 25, 2007)

Zero Cool said:


> isnt that his internal IP adress? the one within the network?


Doubt it. The range is reserved for LANs though yes.


----------



## MrSeanKon (May 29, 2007)

*Go To Statement Considered Harmful* check the link


----------



## Zeratul_uy (May 29, 2007)

aximbigfan said:


> goto is a fucntion thart when runs, goes to a certain area of code. for example:
> 
> MSDOS
> 
> ...



That's just what i thought it was... LOL xD
Kinda complicated isn't it?


----------



## Oliver_FF (May 31, 2007)

This really depends on how you use the goto command. If you use it to break out of a major loop or something, that's some seriously bad misuse of the programming language


----------



## TheMasterOfSinanju (Jun 18, 2007)

Yes, because in VB3-6, where I did most of my learning professionally @ least? It was the ONLY "structured err handling" I knew of!

E.G.-> On Error GoTo

Will I use it now? Not usually, but sometimes, if you keep it going to '1 exit' & don't 'cut back' up into your code, creating spaghetti logic situations? It CAN be useful!

Delphi & VB.NET have something that one of my Technical/Intellectual heroes in Anders Heijelsberg designed in Try-Catch (Delphi has Try Except/Finally) & I'd rather use that though for err traps/custom err-exception handlers though, @ least nowadays!

APK


----------



## MrSeanKon (Jun 28, 2007)

TheMasterOfSinanju said:


> Delphi


This language based on Pascal which designed for students and teaches the programming style.
But Pascal and Delphi has goto. 
IMHO it is a useful statement but we must be careful when use it.


----------

