>I have a program for converting tab-delimited text to codebase foxpro
> databases. One problem at the moment is that d4create doesn't work
> with dynamic arrays of field or tag infos. This means I have to keep a
> static array that is large enough to contain any potential database.
> This leads to ugly code and bad dependencies. Is there any way to make
> a dynamic datastructure that can be passed to d4create successfully
> which is more scientific than just manually packing it into a block of
> memory.
Hello,
Here some snippets of a piece of code I use in CB4 Tables (see
www.tiriss.com/cb4tables)
var
FieldDescs: array of FIELD4INFO;
begin
SetLength(FieldDescs, FieldDefs.Count+1);
for I := 0 to FieldDefs.Count-1 do
begin
with FieldDescs[I] do
begin
Len := FieldDefs[I].Size;
// etc...
end;
end;
FieldDescs[FieldDefs.Count].Name := nil;
// ... lost of other stuff like initializing the tags just like the fields
FCBDATA4 := d4create(Database.CBCODE4, PChar(TablePath),
@[EMAIL PROTECTED]
@[EMAIL PROTECTED]
);
So basically just declare it as a dynamic array, and after that use
setlength to set the length.
I have tested this in D5 - D2006, so I guess it should work for you too.
Regards,
Tjipke van der Plaats
(Author of CB4 tables: the easiest way to use Codebase in Delphi!)
--


|