?
Solved

Create dBase III/IV table with BDE API (5)

Posted on 1998-11-10
5
Medium Priority
?
587 Views
Last Modified: 2013-11-24
Hi experts.
I would like to create a dBase III/IV table with the help of BDE API functions. dbiCreateTable function creates a dBase file, but it is a dBASE 5 table (because my BDE is version 5). Is there any parametar that i can pass to this function so that it creates a dBase II/IV table?
Thx in advance.
0
Comment
Question by:protein
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 4

Expert Comment

by:dwwang
ID: 1346370
Have looked at the example in BDE32.hlp for the dbiCreateTable function? I think the level parameter of a table is the version. So you can have a try to set it to different values to check out whether the expected version is created. (Although I think set level to 4 is proper.)
0
 
LVL 2

Expert Comment

by:333
ID: 1346371
Hi,
in BDE Administrator you can specify, which level of table is created by default.

A.
0
 
LVL 4

Expert Comment

by:dwwang
ID: 1346372
Yes, either way will do the trick. If you want to be able to create different versions of DBase tables, the parameter in the dbicreate table is needed. Below is the example in BDE32.hlp:



Create a table with a different level, block size, and fill factor than specified in the BDE configuration. Most Delphi users should use TTable.CreateTable. This example uses the following input:
      fDbiCreateTable(Database1.Handle, 'TableChange', 3, @FDesc, 7, 32768, 95);

procedure fDbiCreateTable(hTmpDb: hDBIDb; TableName: String; Fields: Word;
             pFlds: pFLDDesc; Level, BlockSize, FillFactor: Word);
var
  pOptDesc, pOrigDesc: pFLDDesc;
  pOptData, pOrigData: pBYTE;
  TblDesc: CRTblDesc;
  sLevel, sBlockSize, sFillFactor: String;

begin
  pOptDesc := AllocMem(3 * sizeof(FLDDesc));
  pOrigDesc := pOptDesc;
  pOptData := AllocMem(20);
  pOrigData := pOptData;
  try
    sLevel := IntToStr(Level);
    sBlockSize := IntToStr(BlockSize);

    sFillFactor := IntToStr(FIllFactor);
    // Set up first parameter
    pOptDesc.iOffset := 0;
    pOptDesc.iLen := Length(sLevel) + 1;
    StrPCopy(pOptDesc.szName, 'LEVEL');
    StrPCopy(PChar(pOptData), sLevel);
    Inc(pOptData, Length(sLevel) + 1);
    Inc(pOptDesc);
    // Set up second parameter
    pOptDesc.iOffset := Length(sLevel) + 1;
    pOptDesc.iLen := Length(sLevel) + 1 + Length(sBlockSize) + 1;
    StrPCopy(pOptDesc.szName, 'BLOCK SIZE');
    StrPCopy(PChar(pOptData), sBLockSize);

    Inc(pOptData, Length(sBlockSize) + 1);
    Inc(pOptDesc);
    // Set up third parameter
    pOptDesc.iOffset := Length(sLevel) + 1 + Length(sBlockSize) + 1;
    pOptDesc.iLen := Length(sLevel) + 1 + Length(sBlockSize) + 1 + Length(sFillFactor) + 1;
    StrPCopy(pOptDesc.szName, 'FILL FACTOR');
    StrPCopy(PChar(pOptData), sFillFactor);
    // Format the table descriptor
    FillChar(TblDesc, sizeof(TblDesc), #0);
    StrPCopy(TblDesc.szTblName, TableName);
    StrCopy(TblDesc.szTblType, szPARADOX);

    TblDesc.iOptParams := 3;
    TblDesc.pFldOptParams := pOrigDesc;
    TblDesc.pOptData := pOrigData;
    TblDesc.iFldCount := Fields;
    TblDesc.pFldDesc := pFlds;
    // Create the table
    Check(DbiCreateTable(hTmpDb, True, TblDesc));
  finally
    FreeMem(pOrigDesc, 3 * sizeof(FLDDesc));
    FreeMem(pOrigData, 20);
  end;
end;
0
 

Author Comment

by:protein
ID: 1346373
Thank u for answering, but there is still a problem:
I have already read the code above, but the LEVEL parametar is described in the BDE help in this way: If you want to create a FOxPro 2.5 table you must create dBase table with an optional LEVEL parametar 25. That is OK for FoxPro, but i want to create a dBase III/IV table.
For example if i pass as Level- 7 that meens Paradox7 table, but what about Level=5??? Is this going to be a Paradox5 or dBase5 table.
About the other comment from A.: I want to make this programmatically(the average user does not know how to use the BDE administrator
0
 
LVL 4

Accepted Solution

by:
dwwang earned 420 total points
ID: 1346374
The parameter of the function also includes a tableType item, in it you can define the table type programmatically, like the statement above:

StrCopy(TblDesc.szTblType, szPARADOX);

you can write StrCopy(TblDesc.szTblType, szDBASE) to create a DBase table.
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

MS Access 2003 or later To MySQL Migration Project Hello All, this is my second article in the category of MS-OFFICE Automation. In internet I am not able to find any comprehensive resource on the Migration of MS Access back-end to MySQL so I fin…
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question