R Maine writes:
> Panagiotis Vossos writes:
>
> I wanted to have an input file
> > that contained the following:
> >
> > TYPEA ...some values for a TYPEA variable go here...
> > or
> > TYPEB ...some values for a TYPEB variable go here...
> >
> > How can we make the main program operate for both these cases ?
> > Into what type of variable should "some values..." be read in ?
>
> You are going to have to have two separate variables, one of each
> type. Or I suppose you can do something like have a single derived
> type that has components of both types, plus a flag to tell which
> component has useful data. That kind of thing can work, but is,
> of course, wasteful of space. If you aren't working with large
> arrays, the space might not matter.
Or one could declare each of the two types as a pointer and only
allocate the space for the one which turns out to be the one you want
to use. You still have to declare for all possible cases, but you
won't be wasting the space.
--
. Paul Stevenson . Research Fellow . University of Surrey .
. phone: +44 (0) 1483 686795 . fax +44 (0) 1483 686781 .
. [log in to unmask] . http://www.ph.surrey.ac.uk/~phs3ps .
. I dream in beige .
|