Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Xbase Codebase > Dynamic create ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 239 of 306
Post > Topic >>

Dynamic create of foxpro files

by "hellokarl" <hellokarl@[EMAIL PROTECTED] > Feb 26, 2006 at 09:02 PM

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.


snippet of existing code starts here

  Ok : Boolean;
  idx : integer;
  FieldInfo : Array [0..100] of Field4Info;
  TagInfo : Array [0..100] of Tag4Info;
begin
  if ( FldHdr.Unicode) then
  begin
    code4safety( CBEng, 0) ;
    Code4Compatibility(CBEng, 30);
  end
  else
    Code4Compatibility( CBEng, 26);

  Code4ReadOnly(CBEng, 0);
  Code4AccessMode(CBEng, OPEN4DENY_RW);

  for idx := 0 to FldHdr.Count -1 do
  begin
    FieldInfo[ idx].Name := StrAlloc( length( FldHdr.Hdr( idx,
Ok).fName)+1);
    StrPCopy( FieldInfo[ idx].name, FldHdr.Hdr( idx, Ok).FName);
    FieldInfo[ idx].aType := FldHdr.Hdr( idx, Ok).fTypeRaw;
    FieldInfo[ idx].Len := FldHdr.Hdr( idx, Ok).fWidth;
  end; //for

  //Always end a field array with NIL
  idx := FldHdr.Count;
  FieldInfo[ idx].name  := Nil;
  FieldInfo[ idx].aType := 0;
  FieldInfo[ idx].len   := 0;
  FieldInfo[ idx].dec   := 0;

  //Now do the tags
  for idx := 0 to Tags.count-1 do
  begin
    TagInfo[ idx].Name := StrAlloc( length( Tags.Tag(idx).tName)+1);
    StrPCopy( TagInfo[ idx].name, Tags.Tag( idx).tName);
    if ( length( Tags.Tag( idx).tExpression)>0) then
    begin
      TagInfo[ idx].expression := StrAlloc( length( Tags.Tag(
idx).tExpression)+1);
      StrPCopy( TagInfo[ idx].expression, Tags.Tag( idx).tExpression);
    end
    else
    begin
      TagInfo[ idx].expression := StrAlloc( length( Tags.Tag(
idx).tName)+1);
      StrPCopy( TagInfo[ idx].expression, Tags.Tag( idx).tName);
    end; {else}
 




 4 Posts in Topic:
Dynamic create of foxpro files
"hellokarl" <  2006-02-26 21:02:57 
Re: Dynamic create of foxpro files
Andrew Clay <Andrew_Cl  2006-02-27 17:20:02 
Re: Dynamic create of foxpro files
"hellokarl" <  2006-02-28 20:03:49 
Re: Dynamic create of foxpro files
"Tjipke A. van der P  2006-03-02 20:45:11 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Thu Jul 24 13:50:44 CDT 2008.