comp.lang.ada
 help / color / mirror / Atom feed
* Representation clauses
@ 1993-06-03 14:44 Jeff Etrick
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Etrick @ 1993-06-03 14:44 UTC (permalink / raw)


Dear Netters,

  I have inherited a program that has been around for a while and the
users have a fair number of files generated from it. With the recent
upgrade of my compiler the binary output files are no longer compatible. In
looking over the code I have noticed the former programmers did not use
any representation clauses for their output records. I have since been
working on adding these to the current system. My problem is I have a
variant record I see no way of putting a representation clause on.

  subtype Small_Natural is NATURAL range 0..300;

  type String_Record (Max_Length : Small_Natural := Small_Natural'Last)
  is record
    Length : Small_Natural := 0;
    Name   : String(1..Max_Length) := (others => ' ');
  end record;
  
  type Catalog
  is record
    File_Name : String_Record;
    File_Description : String_Record;
  end record;

  Since I have been going in and changing things anyway my question is what
is the  best way to change the above so I am not bit again due to version
or a compiler change?

  One idea I was thinking about was writing an Integer(the length) followed
by a fixed length string, Internally the code would still use the variant
records with only the reading and writing of file routines changing.


Thanks for any advice,

Jeff
jeffe@osiris.css.gov

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Representation clauses
@ 1993-06-03 20:24 Mark A Biggar
  0 siblings, 0 replies; 2+ messages in thread
From: Mark A Biggar @ 1993-06-03 20:24 UTC (permalink / raw)


[problem with rep clauses and variant records and binary IO]

Seriously consider not doing your record IO in binary at all.
Write out each record as a line of ascii text with binary values
output in formated ascii.  This has 3 major advantages.

1) It is completely portable, even between programs running on different
	CPU architectures.

2) It is very easy to document and maintain.

3) Makes debugging IO problems trivial because you can check your
	output files by eye.

Unless you have an enormous amount of data or hard real-time constraints
the overhead added by the text parsing is usually insignifficant.  It can
even be faster then binary IO when variant records are involved, because may
compilers tens to write out binary variant records in fixed size record
set at the maximun size, and if most of your record are small this wastes
a lot of space and you will often find that the ascii version of the file
is smaller enough that the saving in disk IO time more then makes up for
the text parsing overhead.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1993-06-03 20:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1993-06-03 14:44 Representation clauses Jeff Etrick
  -- strict thread matches above, loose matches on Subject: below --
1993-06-03 20:24 Mark A Biggar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox