Solved

create a Paradox5 table

Posted on 1998-09-18
9
227 Views
Last Modified: 2010-04-06
Hello.

I want to create a table of 'Paradox 5' type.
Because I want to import this Paradox-type table to MSAccsess
which does't seem to support Paradox7.

Now I create table by 'CreateTable'method. But this table type is
Paradox7. So I can't import it.
Can I create a Paradox5 type table?

Thanks for your help.


Syouchi
0
Comment
Question by:Syouchi
  • 7
  • 2
9 Comments
 
LVL 1

Expert Comment

by:nrobin
ID: 1340113
Syouchi,

Its all about creating a table with a different BDE level.

This list is from BDE.INT.

{ Table levels }

const
  TBLLEVEL3          = 3;               { Paradox level 3 and dBASE level 3+ }
  TBLLEVEL4          = 4;               { Paradox level 4 and dBASE level 4 }
  TBLLEVEL5          = 5;               { Paradox level 5 and dBASE/Win }
  TBLLEVEL7          = 7;               { Paradox level 7 , Win32 }
  FOXLEVEL25         = 25;              { Fox Table (Ver 2.5) }

So using this youcan use the dbiCreateTable function:


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;

USAGE: fDbiCreateTable(Database1.Handle, 'TableChange', 3, @FDesc, 7, 32768, 95);

HTH

Nicholas.
0
 
LVL 1

Expert Comment

by:nrobin
ID: 1340114
BTW, its not that easy! ;)
0
 

Author Comment

by:Syouchi
ID: 1340115
Hmmmm....

you are right.
It's not easy.... :(


Syouchi

0
 
LVL 1

Expert Comment

by:nrobin
ID: 1340116
The bit you need is the FieldDefs, once you have that you should be ok.

Nicholas.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 1

Expert Comment

by:nrobin
ID: 1340117
Syouchi,

Ihave successfully created myself a table using the above with some field defs....I will put it up, but 50 points seems a little too small 8)

Nicholas.
0
 
LVL 1

Accepted Solution

by:
nrobin earned 100 total points
ID: 1340118
const
  DB_LEVEL_5 = 5; // Paradox 5 format

const
      FieldDescriptors: array [0..1] of
            FLDDesc = (
                                          (iFldNum:      1;            { Field Number }
                                           szName:       'FIELD1';     { Field Name }
                                           iFldType:     fldINT32;     { Field Type }
                                           iSubType:     fldUNKNOWN;   { Field Subtype }
                                           iUnits1:      0;            { Field Size }
                                           iUnits2:      0;            { Decimal places ( 0 ) }
                                           iOffset:      0;            { Offset in record ( 0 ) }
                                           iLen:         0;            { Length in Bytes  ( 0 ) }
                                           iNullOffset:  0;            { For Null Bits    ( 0 ) }
                                           efldvVchk:    fldvNOCHECKS; { Validiy checks   ( 0 ) }
                                           efldrRights:  fldrREADWRITE { Rights }
                                          ),
                                          (iFldNum:      2;
                                           szName:       'FIELD2';
                                           iFldType:     fldZSTRING;
                                           iSubType:     fldUNKNOWN;
                                           iUnits1:      254;
                                           iUnits2:      0;
                                           iOffset:      0;
                                           iLen:         0;
                                           iNullOffset:  0;
                                           efldvVchk:    fldvNOCHECKS;
                                           efldrRights:  fldrREADWRITE
                                          )
                                          );


procedure TForm1.Button1Click(Sender: TObject);
begin
  fDbiCreateTable (Database1.Handle, 'MyNewTable', 2,  
  @FieldDescriptors, DB_LEVEL_5, 32768, 95);
end;

Syouchi,

Cut and paste the original function previously into this, then create database component on a form.  Set its aliasname and databasename to the same - I created an alias and made them both the aliasname.  Then test it by creating setting active to true.

e.g.
 New Alias: dbi_test_alias
 database1.aliasname := 'dbi_test_alias';
 database1.databasename := 'dbi_test_alias';
 database1.active := true;

I set these up at design time but you could do it in the button1.click.

Then thats it.  The field defs define two fields FIELD1 as an integer, FIELD2 as a string.  Look in bde.int for definitions.

Hope this warrants better points ;)

Good luck Syouchi.

Regards

Nicholas.


0
 

Author Comment

by:Syouchi
ID: 1340119
Thanks a lot.

Your code is really excellent.
I will give you 100 points.
Is it enough?


Syouchi

0
 
LVL 1

Expert Comment

by:nrobin
ID: 1340120
No probs Syouchi.  The message I received from Expert exchange says I earned "400 quality points"...think there must have been wires crosed ;)

Well done, glad its sorted.

Regards

Nicholas.
0
 
LVL 1

Expert Comment

by:nrobin
ID: 1340121
No need to reply, just realised what expert exchange meant..doh.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
How can I open IE in olecontainer? 7 109
Magic Software info 18 105
Reconfigure Delphi Install? 2 37
Convert a string into a TDateTime 5 46
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now