From: "Michael W. Ryder" <_mwryder@...> Date: 2008-08-28T09:50:22+09:00 Subject: Re: Having a difficult time with Case statements. Chris Bailey wrote: > I am trying to implement a simple frontend for a text adventure that > I'm putting together for ruby practice. My idea was to use case - when > to validate player input and to progress through a menu system, > character creation and the loading of character files. The code runs > cleanly for me but effectively does absolutely nothing. I've exhausted > about every idea I've had for a nice clean format for handling this and > I've decided to ask someone that knows what they are doing. I've > attached the source file in question and I would greatly appreciate it > if someone could have a look and offer me some advice on what I'm doing > wrong or how to better design said system. All feedback is welcome, > Thank you. > > Attachments: > http://www.ruby-forum.com/attachment/2623/startup.rb > Looking at your code it looks like you need to remove the first case statement and use something like a while loop. From what I can see it looks like when you select '2' it changes 'startstate' to 1 and then exits the case statement. An alternative is to set startstate in the main program and then call startUp with the current startstate -- i.e. x = startUp(startstate). Then test x to see if you want to call startUp again or exit the program.