[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

create a Paradox5 table

Posted on 1998-09-18
9
Medium Priority
?
242 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
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…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

650 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