Bernd Ragutt wrote in message ... >Hello! > >I am trying to understand writing to and reading from streams. > >The Ada95 LRM 13.13.2 (26) states "If T has discriminants without (!) >defaults, S�Output ...". > >I have no problems writing and reading records without (!) default >discriminants (using S'Output and S'Input). >But when trying to read a record with (!) a default discriminant (using >S'Output and S'Input), there is an exception. > >What's wrong? > >I do understand the LRM the following way: >For every subtype S of a specific type T, that is, for all (!) types, with >and without default discriminants, writing and reading with S'Output and >S'Input should function. > If the type of the object into which you're reading has default discriminant(s), then you should use a declare block within your read loop, declaring an object of that type, but initialized by the call to the S'input attribute. In that way, the object is constrained by its initialization, and each time through the loop a new object is declared with the appropriate constrains -- thus permitting heterogeneous files to be read. Hope this helps, David C. Hoos, Sr.