ID:164574
 
mob
banker
verb/Bank()
set src in oview(1)
switch(alert("Would you like to deposit or withdraw?","banker","deposit","withdraw","leave"))
if("deposit")
depositing
var/x=input("deposit what?")as null|obj in usr.contents
if(x)
usr.bank+=x
usr.contents-=x
sleep(1)
goto depositing
else
switch(alert("Will there be anything else?","banker","deposit","withdraw","leave"))
if("withdraw")
goto withdrawing
if("deposit")
goto depositing

if("withdraw")
withdrawing
var/x=input("withdraw what?")as null|obj in usr.bank
if(x)
usr.contents+=x
usr.bank-=x
sleep(1)
goto withdrawing
else
switch(alert("Will there be anything else?","banker","deposit","withdraw","leave"))
if("withdraw")
goto withdrawing
if("deposit")
goto depositing

This is my tacky tacky banking system. I thought it up in ten minutes in school. But, it gives me a LOT of runtime errors! What's wrong with it?
Wouldnt this go in "Code Problems"?
I think whats wrong with it, is your using a lot of goto statements.
Oh My God! Noooooooooooooooooooooooooo!

Goto statements are a sign of very bad program design, very bad. Try splitting the proc into multiple ones.
In response to Quest Industries
How d'you mean, a LOT of goto statements? I mean, surely I need to use at least some... would this be any better?
mob
banker
verb/Bank()
set src in oview(1)
switch(alert("Would you like to deposit or withdraw?","banker","deposit","withdraw","leave"))
if("deposit")
usr.deposit()
if("withdraw")
usr.withdraw()
proc/deposit()
start
var/x=input("deposit what?")as null|obj in usr.contents
if(x)
usr.bank+=x
usr.contents-=x
sleep(1)
goto start
else
switch(alert("Will there be anything else?","banker","deposit","withdraw","leave"))
if("withdraw")
usr.withdraw()
if("deposit")
goto start
proc/withdraw()
start
var/x=input("withdraw what?")as null|obj in usr.bank
if(x)
usr.contents+=x
usr.bank-=x
sleep(1)
goto start
else
switch(alert("Will there be anything else?","banker","deposit","withdraw","leave"))
if("withdraw")
goto start
if("deposit")
usr.deposit()

Yes this should probably go in code problems, but it's in developer how-to because it's how-to fix my code problem.

Duh.
____________________
Ok, so that works, now one more thing, how would I make it so that you can't deposit an item you're wearing?

Wait, I got it, man i'm not doing well today =\
Oh and I think i'll tell you my first mistake because it's really funny: i'd written mob/var/list/bank at the top of my code. And it was giving me a runtime. And it took me this long to spot the problem.
In response to Adam753
Adam753 wrote:
How d'you mean, a LOT of goto statements? I mean, surely I need to use at least some... would this be any better?

Eh, you don't even have to use goto statements at all. I prefer not using them at all.