comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Case statement question
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Case statement question [message #42817 is a reply to message #42807] Wed, 23 February 2005 09:19 Go to previous messageGo to previous message
R.G.Stockwell is currently offline  R.G.Stockwell
Messages: 163
Registered: October 2004
Senior Member
"Paul Van Delst" <paul.vandelst@noaa.gov> wrote in message
news:cvib57$7n3$1@news.nems.noaa.gov...
>> How about
>>
>> switch x of
>> 0: do_this() & break
>> 1:
>> 2:
>> ...
>> 9: do_that() & break
>> 10: do_something_else() & break
>> 11: do_something_more() & break else: whatever()
>> endswitch
>
> Oooo - I prefer this to the solution I posted. Looks cleaner.

I disagree with you Paul, I like your solution best.
In fact I was about to post a response, and then saw yours, and
sent my inelegant solution to the intergalactic bitbucket in the sky.
I don't think the above is really any different than the original question
(it is easy to paste do_that(x) 10 times.)

> Of course, I prefer the Fortran solution above all:

> SELECT CASE (x)
> CASE (0); do_this()
> CASE (1:9); do_that(x)

COOL!
How about something along the lines of:
commandstrings = strarray(12)
commandstrings[0] = 'do_this()'
commandstrings[1:9] = 'do_that(x)'
commandstrings[10] = 'do_something_else()'
commandstrings[11] = 'do_something_more()'
commandstrings[12] = 'do_elsedefault()'

r = execute(commandstring[x])

NOTE: the
commandstrings[12] = 'do_elsedefault()'
takes advantage of IDLs array overrun "feature" where any x
gt 11 will call that last element (thereby reproducing the effect of the
"else" statement in the case command).

Cheers,
bob
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Singular jacobian in broyden
Next Topic: Putting bands together

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 20:16:34 PDT 2025

Total time taken to generate the page: 0.96266 seconds