News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

dbf Header and STRUCT question

Started by anon, January 30, 2005, 08:03:03 PM

Previous topic - Next topic

anon

I want to use dBASE tables directly from my asm program. I'm having a little trouble
figuring out how to initialize the dbf header structure. The Header structure contains
a variable number of Field Descriptor structures. How do I properly declare an unknown
number of Field Descriptors in the Header ?

dbfFIELD_DESCRIPTOR STRUCT
FieldName   BYTE 11 dup(?) ;0-10, 11 bytes, Field name in ASCII (zero-filled).
FieldType   BYTE  ?        ;Field type in ASCII (C, D, F, L, M, or N).
Reserved1   BYTE  4 dup(?) ;Reserved.
FieldLength BYTE  ?        ;Field length in binary.
FieldCount  BYTE  ?        ;Field decimal count in binary.
Reserved2   BYTE  2 dup(?) ;Reserved.
WorkArea    BYTE  ?        ;Work area ID.
Reserved3   BYTE 10 dup(?) ;Reserved.
mdxFlag     BYTE  ?        ;Production MDX field flag; 01H if field has an
                           ;index tag in the production MDX file, 00H if not.
dbfFIELD_DESCRIPTOR ENDS

dbfHEADER STRUCT
Valid       BYTE ?         ;Valid dBASE IV file. bits 0-2 indicate version
                           ;number, bit 3 the presence of a dBASE IV memo
                           ;file, bits 4-6 the presence of an SQL table, bit
                           ;7 the presence of any memo file (either dBASE III
                           ;PLUS or dBASE IV).
LastUpdate  BYTE  3 dup(?) ;Date of last update; formattted as YYMMDD.
NoRecords   DWORD ?        ;Number of records in the file.
NoHdrBytes  WORD  ?        ;Number of bytes in the header.
NoRcdBytes  WORD  ?        ;Number of bytes in the record.
Reserved1   BYTE  3 dup(?) ;Reserved; fill with 0.
iFlag       BYTE  ?        ;Flag indicating incomplete transaction.
eFlag       BYTE  ?        ;Encryption flag.
MultiUser   BYTE 12 dup(?) ;Reserved for dBASE IV in a multi-user environment.
mdxFlag     BYTE  ?        ;Production MDX file flag; 01H if there is an MDX, 00H if not.
ID          BYTE  ?        ;Language driver ID.
Reserved2   BYTE  2 dup(?) ;Reserved; fill with 0.
FieldArray  dbfFIELD_DESCRIPTOR ? dup(<>) ;32 bytes each  Field descriptor array (see above). MY PROBLEM IS HERE
FieldTerm   BYTE  ?        ;0DH as the field terminator.
dbfHEADER ENDS

tenkey

Quote from: anon on January 30, 2005, 08:03:03 PM
I want to use dBASE tables directly from my asm program. I'm having a little trouble
figuring out how to initialize the dbf header structure. The Header structure contains
a variable number of Field Descriptor structures. How do I properly declare an unknown
number of Field Descriptors in the Header ?
You separate it from the fixed size part. In others words, redefine it so that it isn't part of the "header".

At best, you can define one Field Descriptor to establish the offset of the first Field Descriptor.
A programming language is low level when its programs require attention to the irrelevant.
Alan Perlis, Epigram #8

anon

Thanks, that is what I'm doing. The other thing I thought about was declaring 255
Field Descriptors (the max allowed for dBASE IV). I was just hoping there was another way.

P1

You can also use the ODBC/ADO Asm stuff to create the file at a little higher level.

Regards,  P1  :8)