0% found this document useful (0 votes)
16 views5 pages

Pro Fit File Formats

Uploaded by

billnunneh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views5 pages

Pro Fit File Formats

Uploaded by

billnunneh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 5

The standard pro Fit file format

Starting with version 6.0, pro Fit uses a unified file format for all its native files. This
note describes the general structure of this file format as the basics required to write
simple data or function files.

Note that the most simple files to be loaded as functions or data into pro Fit are pure
text files (non-unicode, non-rtf, non-html), such as tab-delimited or comma separated
files. These file formats are not described here.

Overview

Each native pro Fit file starts with a header. The header looks like this:

typedef struct
{
SInt32 creator; // always 'NLft'
SInt32 type; // the file type:
// 'ftFC' for function files
// 'ftLS' for data files
// 'ftGF' for drawing files
// 'ftAA' for drawing files in dialog
mode
// 'ftCD' for saved function/program
code
SInt32 headerVersion; // the version of this header, presently
0x1000 (or larger)
SInt32 requiredForReading; // the pro Fit version (e.g. 0x560) that is
required for
// reading this file at least partially
SInt32 recommendedForReading; // the pro Fit version (e.g. 0x600) that
is required for
// reading this file completely
SInt32 reserved[5]; // presently unused and set to 0
} StandardHeader;

When you write a pro Fit file from some custom code of yours, you probably will set
requiredForReading and recommendedForReading to 0x600, thereby indicating pro Fit
6.0.0.

Following the above headers, pro Fit files contain so called "chunks" of data. Each
chunk has the following format

struct
{
SInt32 chunkType; // the type of the chunk of data that
follows, 0 for
// the last chunk
SInt32 chunkInfo; // presently 0
UInt64 chunkSize; // the size of the chunk of data that follows
... data; // the data
}

The data following the chunkSize field can be any size, as defined in the chunkSize
field, and its contents depend on the type of the chunk.

When pro Fit parses a file, it reads all chunks it finds, skipping any chunk that is not
defined for a given file type. pro Fit stops reading the file, when it runs into a chunk
with chunkType = 0.

Data files

A pro Fit data file starts with the StandardHeader defined above, with the type field
set to 'ftLS'.

The first chunk of data following the header should be a chunk of type 'Size', the data
of which must contain the following three entries:

SInt32 nrColumns; // the number of columns in the window


SInt32 nrRows; // the number of rows in the window
SInt32 firstColumn; // the index (1-based) of the first non-empty
column

For each column starting from firstColumn, there must be a 'ColN' chunk followed
by a 'Data' chunk, as explained in the following.

The 'ColN' chunk is a chunk whose chunkType field is set to 'ColN', and its data
chunk looks like this:

UInt8 type; // The column type. 0 for 4-byte wide floating point numbers,
// 1 for 8 byte wide floating point numbers,
// 2 for 8 byte wide floating point numbers representing
dates
// 3 for 8 byte wide floating point numbers representing
time
// 128 for text columns.
UInt8 n; // Additional info, depending on value above, by default
always set to 0
// for numeric columns:
// bits0-3: the number of decimals +1 (0: auto)
// bit7: 1 if scientific, 0 else
// for type == 2: bit7: show Time, bit6: show Seconds,
// bits4-5: date format (0=short, 1=long, 2=abbrev.)
// for type == 3: bits0-3: the number of decimals +1 (0:
auto)
UInt8 width; // the width of this column * 4.5 / fontSize, where fontSize is
the
// window's font size (default: 12). Set this field to 0 for
// using the default width
UInt8 form; // display format for dataTime (which units)
// bit1-bit7: seconds, minutes, hours, days, weeks,
months, years, centuries
// 0x00: default (y d h:m:s.ssss)
UInt8 nameLen; // the length of the following name
UInt8 name[...]; // the name

The 'Data' chunk is a chunk whose chunkType field is set to 'Data' and that contains
the actual data in the given column. The data in the 'Data' chunk looks as follows
SInt32 type; // The data type to follow:
// 'sing' for columns with 4-byte big-endian
floating point numbers
// 'doub' for columns with 8-byte big-endian
floating point numbers
// (also used for date and time columns)
// 'ftSG' for columns with 4-byte little-endian
floating point numbers
// 'ftDB' for columns with 8-byte little-endian
floating point numbers
// (also used for date and time columns)
// 'TEXT' for text columns
SInt32 size; // the number of bytes in the following array

If type == 'sing' (or 'ftSG') or type == 'doub'(or 'ftDB') , the size entry is followed by an
array of 4 or 8 byte floating point numbers.

If type == 'TEXT', the size entry is followed by an SInt32 defining the number of rows
in the column and then by the data. The data for text columns is a sequence of
Pascal strings, each string consisting of a leading length byte (having a value of 0
through 255) and the corresponding characters following it.

A pair of 'ColN' and 'Data' chunks is required for each column. The pairs repeat until
all columns have been defined. The file ends with a chunk having its chunkType set
to 0.

Function files

A pro Fit function file starts with the StandardHeader defined above, with the type
field set to 'ftFC'.

The main chunk of data following the header should be a chunk of type 'utxt', the
functions text in unicode format:

UniChar unicodeByteOrderMark; // 0xFEFF


UniChar[] funcText; // the function text in unicode format

Another chunk of data of type 'SCol' defines whether the syntax coloring is active:

UInt8 syntaxColoringOn; // 1 (true) if syntax coloring is active, 0 otherwise

Data or Function or Drawing files

Besides a common header, pro Fit files have some common chunks as well.

The info / comment chunk has the type 'inf1', and contains the following data:

UniChar unicodeByteOrderMark; // 0xFEFF


UniChar[] text; // the info or comment in unicode format
The window position chunk has the type 'wpos', and contains data to position and
size the window:

short top; // top window coordinate (signed 2 bytes)


short left; // left window coordinate (signed 2 bytes)
short bottom; // bottom window coordinate (signed 2 bytes)
short right; // right window coordinate (signed 2 bytes)

The window font chunk has the type 'font', and contains data to position and size the
window:

Fixed size; // font size as: 16-bit signed integer plus 16-bit fraction
Style style; // sum of individual style elements, i.e. 0: plain, 1: bold,
// 2: italic, 4: underline, 0x20: condense,
0x40: extend
unsigned char font[128]; // the font name, e.g. 'Geneva', 'Helvetica',
'Times'

The meta data chunk has the type 'meta', and contains some meta data in XML
(visible under 'Window Properties' in pro Fit). Use the following XML format and copy
your information in the appropriate places:

<?xml version="1.0" encoding="UTF-8"?>


<!DOCTYPE plist>
<plist version="1.0">
<dict>
<key>kMDItemAuthors</key>
<array>
<string>Your first author</string>
<string>Your second author</string>
</array>
<key>kMDItemCopyright</key>
<string>Your copyright</string>
<key>kMDItemKeywords</key>
<array>
<string>Your first keyword</string>
<string>Your second keyword</string>
</array>
<key>kMDItemProjects</key>
<array>
<string>Your first project</string>
<string>Your second project</string>
</array>
<key>kMDItemVersion</key>
<string>Your version</string>
<key>kMDItemWhereFroms</key>
<array>
<string>Your first where from</string>
<string>Your second where from</string>
</array>
</dict>
</plist>
Endian-ness

Note that, unless noted otherwise, all data in a pro Fit file must be big-endian.

You might also like