Print

Print


On 13 Jan 2005 at 02:31 PST, 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
>     ...
> ...

There's been some odd suggestions and much griping about this, but I thought
I'd make my own contribution:

     DO I=INDEX,1,-1
        SELECT CASE(I)
        CASE(10)
           ! 10 stuff
        CASE(9)
           !  9 stuff
        ...
        END SELECT
     END DO

Increases your code length by 3 lines, is quite clear, no code duplication.

It's also amenable to automated replacement of existing code.

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)