Alex Ostapo
Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:How to convert from Paradox 5 to Paradox 7 format
QuoteMarz wrote: > How can tables be converted from 'Paradox 5 for Windows' format to 'Paradox > 7' format? > (Of course it's needless to say that it is essential to keep all data > intact... ;-)
Well, here is some code I took at http://www.inprise.com in developer support devision, BDE examples. RestructureTable(Table1, 'LEVEL', '7') is exactly what you need. // --------------------------------------------------------------------------- // Purpose: Use the pOptData portion of DbiDoRestructure. // Remarks: This function calls DbiDoRestructure with the Option to change // and the OptData which is the new value of the option. Since a // database handle is needed and the table cannot be opened when // restructuring is done, a new database handle is created and set // to the directory where the table resides. // Example: RestructureTable(Table1, 'LEVEL', '7') // Change table level to 7 // RestructureTable(Table1, 'BLOCK SIZE', '4096') // Change table block size to 4096 // procedure RestructureTable(Table: TTable; Option, OptData: string); var hDb: hDBIDb; TblDesc: CRTblDesc; Props: CurProps; pFDesc: FLDDesc; begin // If the table is not opened, raise an error. Need the table open to get // the table directory. if Table.Active <> True then raise EDatabaseError.Create('Table is not opened'); // If the table is not opened exclusively, raise an error. DbiDoRestructure // will need exclusive access to the table. if Table.Exclusive <> True then raise EDatabaseError.Create('Table must be opened exclusively'); // Get the table properties. Check(DbiGetCursorProps(Table.Handle, Props)); // If the table is not a Paradox type, raise an error. These options only // work with Paradox tables. if StrComp(Props.szTableType, szPARADOX) <> 0 then raise EDatabaseError.Create('Table must be of type PARADOX'); // Get the database handle. Check(DbiGetObjFromObj(hDBIObj(Table.Handle), objDATABASE, hDBIObj(hDb))); // Close the table. Table.Close; // Setup the Table descriptor for DbiDoRestructure FillChar(TblDesc, SizeOf(TblDesc), #0); StrPCopy(TblDesc.szTblName, Table.Tablename); StrCopy(TblDesc.szTblType, szParadox); // The optional parameters are passed in through the FLDDesc structure. // It is possible to change many Options at one time by using a pointer // to a FLDDesc (pFLDDesc) and allocating memory for the structure. pFDesc.iOffset := 0; pFDesc.iLen := Length(OptData) + 1; StrPCopy(pFDesc.szName, Option); // The changed values of the optional parameters are in a contiguous memory // space. Sonce only one parameter is being used, the OptData variable // can be used as a contiguous memory space. TblDesc.iOptParams := 1; // Only one optional parameter TblDesc.pFldOptParams := @pFDesc; TblDesc.pOptData := @OptData[1]; try // Restructure the table with the new parameter. Check(DbiDoRestructure(hDb, 1, @TblDesc, nil, nil, nil, False)); finally Table.Open; end; end; -- SY, Alex 0stapov, japh. CDPI: 922447890 mailto:os...@sumy.com ICQ: 29215380
|