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 #42831 is a reply to message #42819] Tue, 22 February 2005 15:57 Go to previous messageGo to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
David Fanning wrote:
> Michael Wallace writes:
>
>> case x of
>> 0: do_this()
>> 1: do_that(x)
>> 2: do_that(x)
>> 3: do_that(x)
>> 4: do_that(x)
>> 5: do_that(x)
>> 6: do_that(x)
>> 7: do_that(x)
>> 8: do_that(x)
>> 9: do_that(x)
>> 10: do_something_else()
>> 11: do_something_more()
>> endswitch
>>
>> Is there a way to group 1 - 9 into a single expression rather than
>> having to list each distinct number in the range?
>
> I can't tell if this is too obvious or I'm being dense:
>
> case x of
> 0: do_this()
> 10: do_something_else()
> 11: do_something_more()
> else: do_that(x)
> endcase

Another you might not have thought of:

case 1B of
(x ge 0) and (x le 9): do_that(x)
x eq 10: do_something_else()
x eq 11: do_something_more()
else: crash_and_burn
endcase

It's a bugger to indent, though.


--
Mark Hadfield "Ka puwaha te tai nei, Hoea tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
[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 17:04:49 PDT 2025

Total time taken to generate the page: 1.19789 seconds