--
You received this message because you are subscribed to the Google Groups "Harbour Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-deve...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/harbour-devel/a6c1b2a6-8b3e-4c8b-9115-d948b3468286n%40googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/harbour-devel/971b54fd-6f22-48ad-9c6c-05fa0fedff31n%40googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/harbour-devel/38e6bc37-b692-491d-bbf7-f287a3e7a006n%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Harbour Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-deve...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/harbour-devel/acc84b52-bb89-47d0-ba89-a0f15f92ee4an%40googlegroups.com.
To create a function that returns whether a memo field is empty, you need to understand the structure of how the DBF and FPT files are designed.
In the DBF file, each memo field occupies exactly 10 bytes per record. These bytes contain a 32-bit binary pointer (first 4 bytes) that indicates the position of the memo's first block in the FPT file (multiplied by the block size, typically 64 bytes); if it's 0x00000000, the field is empty. The remaining 6 bytes are padded with spaces (0x20) and are not used for length or end markers.
FPT File Structure
The FPT file begins with a 512-byte header (8 blocks of 64 bytes), where the first 4 bytes indicate the total number of blocks used and bytes 6-7 define the block size (default 64). Each memo data block (starting from block 15) follows this internal 8-byte structure:
Bytes 0-3: Total number of blocks that make up this complete memo (little-endian uint32).
Bytes 4-7: Length in bytes of this specific block's content (little-endian uint32).
The actual data follows immediately after, and long memos use multiple blocks linked sequentially without trees or complex pointers, only by linear position.
Size and Empty Field Management
To detect if a memo is empty or calculate its approximate size without traversing all blocks, read only the first 8 bytes of the first FPT block using the DBF pointer: if the number of blocks is 0, it's empty; the total size is (number_of_blocks × block_size) minus header overhead. This fixed-block sequential structure allows efficient access but requires at least reading the first block for precise length, since the DBF doesn't store this information.
To implement this, you need to create a function in C that performs this procedure.
Attached is a DBF/FPT file examined with a hexadecimal editor.
HxD - Freeware Hex Editor and Disk Editor
https://mh-nexus.de/en/hxd/

