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 --
execution falls through to the next block, as in C, so if (say)
index=9, the blocks of code labelled 108, 107 etc are to be executed
as well as the block labelled 109. Each block is quite large, so
repeating them is not sensible. I could get the same result using the
code
select case (index)
case(10)
goto 110
case(9)
goto 109
...
end select
but that is horribly clumsy. Arranging the blocks in the reverse order
and testing index after each one is a bit better but still relatively
clumsy.
Is there a neat way to do what I want without using the computed GOTO?
Could it be that (horrors) the computed GOTO has some uses after all?
--
Anthony Stone http://www-stone.ch.cam.ac.uk/
University Chemical Laboratory, Email: [log in to unmask]
Lensfield Road, Phone: +44 1223 336375
Cambridge CB2 1EW Fax: +44 1223 336362
|