ID:170804
 
Hey, I was looking at goto, and thought i'd try using it, but I'm not sure if I should find another way to do what I need to get done. Would this be a good way to use goto? :

(EXAMPLE)
        Complaint()
set name = "Submit Complaint"
set desc = "Submit Complaint"
set category = "Commands"
var/Message
var/A
var/Choice
var/ping
Message = input("What would you like to say?)as null|message
if(!Message){return}
A = copytext(Message,1,2001)
Choice = input("Are you sure you'd like to send a complaint?")in list("Yes","No")

if(Choice == "Yes")

goto Ping
return



StartServer
startup("D:/Documents and Settings/Owner/My Documents/CentralServer/CentralServer.dmb",1747,"-trusted")
goto Ping

Ping
ping = world.Export("BYOND://68.12.179.184:1747?ping")
if(ping)
A += "\n--[src], [time2text(world.realtime)]"
world.Export("BYOND://68.12.179.184:1747?Complaint: [A]")
src << "Thank you for your time, your opinion is appreciated."
return
else
if(OnceFailed)
src << "I am sorry, but I am truly trying to get this fixed, please give me time to work out this bug."
return
OnceFailed = 1
src << "Error: The Central Server is Down. Please allow me to start it back up again, so we can get your complaint through."
goto StartServer


I have horrible habits, lol :P.

Note: The OnceFailed thing was for debugging purposes, I had to figure out where my error was, and when I didn't have that in there it'd startup the server over and over again because Topic() wouldn't respond in the proper way.
To tell you the truth, goto shouldn't be used unless you have a loop so complex that it defies me being able to think of an example.
In response to Wizkidd0123
Wizkidd0123 wrote:
To tell you the truth, goto shouldn't be used unless you have a loop so complex that it defies me being able to think of an example.

This is too annoying to do any other way >_<

Annoying as in: Will Take Hours.
Nope, this is a bad use of goto. Looks like you need to split this up into a couple of procs at least.

Lummox JR
In response to Lenox
Then do as Lummox said and split it up into procs :). As in, proc/Execute_Ping() :)
In response to Wizkidd0123
Well, that took alot less time than I thought it would, I'm almost done with my third set of procs( This is for a "reporting system" I'm making for my game :P)