On Sun, 2008-08-10 at 16:51 -0400, Francisco Reyes wrote: > Michael Van Canneyt writes: > > > You can also try the Classes unit if you use object oriented programming. > > Each component can write itself to stream. > > Played a little bit with the Classes unit. > Don't really see any benefit over justin writing records directly. > Am I missing something? > > Also when reading back, on both cases(class or directly using records) it > seems I need to use fixed length records. At least based on the examples I > have seen so far. Is there a way to save variable length records and then > read them back?
Normally you write the length as a prefix before the record, typically as some kind of integer type (e.g. LongWord or TsSize). When you read the record later you read the length prefix first, then read the number of bytes that the prefix specified. As a rough and ready example: in_file := FpOpen('input_data.dat', O_RdOnly); . { Other stuff goes here. } . bytes_read := FpRead(in_file, record_len, sizeof(record_len)); bytes_read := FpRead(in_file, buf_area, record_len); Incidentally, from your first message in this thread, you said you were writing an OLAP application. You might care to look at PostgreSQL as a database manager. It does rather nice OLAP functionality, straight out of the box -- and it's free. Regards, Dave [RLU#314465] ====================================================== [EMAIL PROTECTED] (David W Noon) ======================================================
signature.asc
Description: This is a digitally signed message part
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal