Re: procedure in case statement [message #82130 is a reply to message #82049] |
Mon, 19 November 2012 12:13   |
Russell Ryan
Messages: 122 Registered: May 2012
|
Senior Member |
|
|
On Monday, November 19, 2012 10:57:00 AM UTC-5, hann...@web.de wrote:
> thanks a lot, paulv and DavidF. now it works.
>
> i'm sorry if my question was formulated kind of inconvenient and ineffectively - it was my first post and i will work on that.
>
> hannah
Hi Hannah,
Yeah the problem your having is that IDL will default a datatype as a float, and you're trying to assign it a float. So, you need to explicitly set the type to string before hand. When I do this, I usually do:
ans='proc1' ; or the default setting
read,'Which procedure do you want to run: ',ans
case ans of
'proc1':
'proc2':
endcase
But, this can be very dangerous for a slew of reasons. (1) what if the user misspells the procedure? (2) what if they type something that's disallowed? (which I guess is like (1)), (3) what if they capitalize? Obviously, you can see a host of problems. To guard against these things you should set default settings, have an "else" clause in your case, and check capitalization.
Good luck,
Russell
|
|
|