Print

Print


On 13 Jan 2005 at 03:47 PST, Keith Refson wrote:
>
> Anthony Stone wrote:
>> I have a program in which I use the structure
>>
>> go to (101,102,103,104,105,106,107,108,109,110), index
>> 110 stuff
>>     ...
>> 109 more stuff
>>     ...
>> 108 and so on
>>     ...
>> ...
>>
>>
>> The computed GOTO used here is an obsolescent feature, but there
>> doesn't seem to be an obvious replacement. A CASE construct isn't
>> suitable, because there is no jump out at the end of each block --
>
> If your problem is sufficiently regular, how about something along these lines
>
> do i=index,1,-1
>    select case(i)
>       case (10)
>         .. stuff
>       case (9)
>         ... more stuff
>       ...
>     end select
> end do
>
> Keith Refson

Sorry, Keith, when I posted my response I hadn't registered yours.  Mine was a
duplication.

As I said before, this adds 3 more lines to the original code length and is
very clear.  You needn't have qualified your suggestion, though.  I don't
think there is any extra requirement for the code to be regular.  Anthony
clearly stated that the situation was a fall-through, and this DO loop form
satisfies that just fine.

Ted
--
 Ted Stern                                 Applications Group
 Cray Inc.                               office: 206-701-2182
 411 First Avenue South, Suite 600         cell: 206-383-1049
 Seattle, WA 98104-2860                     FAX: 206-701-2500

 Frango ut patefaciam -- I break that I may reveal
 (The Paleontological Society motto, equally apropos for debugging)