?
Solved

create a Paradox5 table

Posted on 1998-09-18
9
Medium Priority
?
241 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
[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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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
 
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 400 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

765 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