Robert,

If I understand Hugo correctly, he mentioned that some of the data he wants
to save is "like" an Excel spreadsheet. He actually needs to save a number
of different data types, most of which are binary.

The Jedi code you reference looks like it is specific to an actual Excel file.

Glenn Lawler
www.incodesystems.com

-----Original Message-----
From:   Robert Alderton [SMTP:[EMAIL PROTECTED]
Sent:   Thursday, January 10, 2008 10:46 AM
To:     advanced_delphi@yahoogroups.com
Subject:        RE: [advanced_delphi] Structured File Format

Actually the Jedi code library looks like it has pre-cooked routines

http://www.koders.com/delphi/fid2AAB471E324D02F7983954B055CC906917F14DD0.aspx


-----Original Message-----
From: advanced_delphi@yahoogroups.com
[mailto:[EMAIL PROTECTED] On Behalf Of Glenn B. Lawler
Sent: Thursday, January 10, 2008 11:38 AM
To: 'advanced_delphi@yahoogroups.com'
Subject: RE: [advanced_delphi] Structured File Format

Hugo,

The easiest way to do what you are talking about is a tagged
binary file.

Here's how I would do it:

Define a set of fixed length "tags" you want to use to define
anything that could be in your file format.

When you write the file do this:

- Write the fixed length tag to the file
- Write a 32-bit integer which is the length of the data
- Write the data

When you read the file do this:

- Read the fixed length tag from the beginning of the file
- Read the length integer
- Call a routine in your program that knows how to read
  the data based on the tag.
- Read the data from the file
- Repeat until you reach the end of the file or a sentinal
  (a special tag that means you have reached the end of
  the file)

The sentinal method is good because your program can
easily detect when a file has been truncated.

Glenn Lawler
www.incodesystems.com

-----Original Message-----
From:   Hugo Massieri [SMTP:[EMAIL PROTECTED]
Sent:   Thursday, January 10, 2008 10:14 AM
To:     advanced_delphi@yahoogroups.com
Subject:        Res: [advanced_delphi] Structured File Format

Glenn,

Thank you for your help!

I believe that a file based only in a record type would not be a good
idea 
because the data is not uniform. But I will certainly think more
seriously 
about the memory buffer.

It will need to save diferent kinds of data at once in the same file,
for 
instance: text elements, graphic images, an array of record data...

I am looking for some info on working/coding with BIFF (Binary
Interchange 
File Format - the MSExcel ones) due to its similarities with my app
needs.

Have you ever heard about this format? Have some info about? Perhaps a 
start book. pdf, website, etc

Any other ideas?

Once again, thank you a lot!

Hugo

eof

----- Mensagem original ----
De: Glenn B. Lawler <[EMAIL PROTECTED]>
Para: "advanced_delphi@yahoogroups.com"
<advanced_delphi@yahoogroups.com>
Enviadas: Quinta-feira, 10 de Janeiro de 2008 13:40:31
Assunto: RE: [advanced_delphi] Structured File Format

Hugo,

If you are clear about how to do file I/O to a binary file,
the rest is straightforward. It sounds like you are trying
to write a fixed record length file. There are multiple ways
to do this in Pascal. The language supported method
involves "File of type". Check the Delphi help for this.
The basic idea is that you define a record type in Pascal
and then read and write these records. That is the simplest
way to deal with such a file, but it is also the least flexible.
The record type must be defined in Pascal code, so your
program will only be able to read and write record types
you have defined in code.

Another way that is indefinitely flexible, is to create a
memory buffer that is the length of the record (using GetMem,
or AllocMem) and then copy fields using move (see Delphi help),
and SizeOf (to know how many bytes to move). You then use
the binary file routines to read and write the buffer. This allows
you to write a single program that can read any kind of record.
To randomly access a record, you position the file pointer in
multiples of the record length and then read or write to the
file.

On the other hand, if all you are trying to do is read and write
a two dimensional grid of data, another way is to use a delimited
file. Tab delimited is the easiest to deal with since a tab character
(ASCII 9) is usually not allowed in the data itself. The advantage
to a delimited file is that you can load it with a text editor to
examine
the data. The disadvantages are read and write is slower, no random
access, and the files are usually larger.

Hope this helps, let us know what else you need to get started.

Glenn Lawler
www.incodesystems. com

-----Original Message-----
From: Hugo Massieri [SMTP:hugomassieri@ yahoo.com. br]
Sent: Thursday, January 10, 2008 8:14 AM
To: advanced_delphi@ yahoogroups. com
Subject: [advanced_delphi] Structured File Format

Hi All!

I am looking for some good information about structured file format
programming, in order to save data from a Delphi application.

The basics on create/open/ save binary file is ok, but unfortunately
have
been hard to find some useful information on the net about how to
structure 
in order to save the data.

The books i have found generally talk about graphic file format but i
would 
like to save data as similar as an Excel spreadsheet.

Any addicional information will be very appreciated, even better if
accompained by some Delphi samples.

Thanks in advance.

Hugo



 
Yahoo! Groups Links





 
Yahoo! Groups Links



Reply via email to