dbftool.lpr 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. program dbftool;
  2. {
  3. Reads and exports DBF files.
  4. Can create a set of 2 demo DBF files to test with.
  5. Demonstrates creating DBF tables, filling it with data,
  6. and exporting datasets.
  7. }
  8. {$mode objfpc}{$H+}
  9. uses {$IFDEF UNIX} {$IFDEF UseCThreads}
  10. cthreads, {$ENDIF} {$ENDIF}
  11. Classes,
  12. SysUtils,
  13. CustApp,
  14. DB,
  15. dbf,
  16. dbf_fields,
  17. dbf_common,
  18. dateutils,
  19. fpdbexport,
  20. fpcsvexport,
  21. fpdbfexport,
  22. fpfixedexport,
  23. fprtfexport,
  24. fpsimplejsonexport,
  25. fpsimplexmlexport,
  26. fpsqlexport,
  27. fptexexport,
  28. fpxmlxsdexport;
  29. type
  30. { TDBFTool }
  31. TDBFTool = class(TCustomApplication)
  32. private
  33. // Exports recordset to specified format
  34. procedure ExportDBF(var MyDbf: TDbf; ExportFormat: string);
  35. // Executable name without path
  36. function GetExeName: string;
  37. protected
  38. procedure DoRun; override;
  39. public
  40. constructor Create(TheOwner: TComponent); override;
  41. destructor Destroy; override;
  42. procedure WriteHelp; virtual;
  43. end;
  44. // Creates 2 demonstration DBFs in Directory
  45. // with dbase compatibility level TableLevel
  46. procedure CreateDemoDBFs(Directory: string; TableLevel: integer);
  47. // Data structure and data adapted from Firebird employee sample database
  48. // Useful to integrate with SQLDB tutorials on Lazarus wiki
  49. var
  50. NewDBF: TDBF;
  51. i: integer;
  52. begin
  53. NewDBF := TDBF.Create(nil);
  54. try
  55. if Directory = '' then
  56. NewDBF.FilePath := '' { application directory}
  57. else
  58. NewDBF.FilePathFull := ExpandFileName(Directory) {full absolute path};
  59. if TableLevel <= 0 then
  60. NewDBF.TableLevel := 4 {default to DBase IV}
  61. else
  62. NewDBF.TableLevel := TableLevel;
  63. NewDBF.TableName := 'customer.dbf';
  64. writeln('Creating ', NewDBF.TableName, ' with table level ', NewDBF.TableLevel);
  65. if TableLevel >= 30 {Visual FoxPro} then
  66. begin
  67. NewDBF.FieldDefs.Add('CUST_NO', ftAutoInc);
  68. end
  69. else
  70. NewDBF.FieldDefs.Add('CUST_NO', ftInteger);
  71. NewDBF.FieldDefs.Add('CUSTOMER', ftString, 25);
  72. NewDBF.FieldDefs.Add('CITY', ftString, 25);
  73. NewDBF.FieldDefs.Add('COUNTRY', ftString, 15);
  74. NewDBF.CreateTable;
  75. NewDBF.Open;
  76. for i := 1 to 5 do //keep size manageable until we have working files
  77. begin
  78. NewDBF.Append;
  79. if (NewDBF.FieldDefs.Find('CUST_NO').DataType <> ftAutoInc) then
  80. NewDBF.FieldByName('CUST_NO').AsInteger := i;
  81. case i of
  82. 1:
  83. begin
  84. NewDBF.FieldByName('CUSTOMER').AsString := 'Michael Design';
  85. NewDBF.FieldByName('CITY').AsString := 'San Diego';
  86. NewDBF.FieldByName('COUNTRY').AsString := 'USA';
  87. end;
  88. 2: //Let's try a duplicate row
  89. begin
  90. NewDBF.FieldByName('CUSTOMER').AsString := 'Michael Design';
  91. NewDBF.FieldByName('CITY').AsString := 'San Diego';
  92. NewDBF.FieldByName('COUNTRY').AsString := 'USA';
  93. end;
  94. 3:
  95. begin
  96. NewDBF.FieldByName('CUSTOMER').AsString := 'VC Technologies';
  97. NewDBF.FieldByName('CITY').AsString := 'Dallas';
  98. NewDBF.FieldByName('COUNTRY').AsString := 'USA';
  99. end;
  100. 4:
  101. begin
  102. NewDBF.FieldByName('CUSTOMER').AsString := 'Klämpfl, Van Canneyt';
  103. NewDBF.FieldByName('CITY').AsString := 'Boston';
  104. NewDBF.FieldByName('COUNTRY').AsString := 'USA';
  105. end;
  106. 5:
  107. begin
  108. NewDBF.FieldByName('CUSTOMER').AsString := 'Felipe''s Bank';
  109. NewDBF.FieldByName('CITY').AsString := 'Manchester';
  110. NewDBF.FieldByName('COUNTRY').AsString := 'England';
  111. end;
  112. end;
  113. NewDBF.Post;
  114. end;
  115. NewDBF.Close;
  116. finally
  117. NewDBF.Free;
  118. end;
  119. NewDBF := TDBF.Create(nil);
  120. try
  121. if Directory = '' then
  122. NewDBF.FilePath := '' {application directory}
  123. else
  124. NewDBF.FilePathFull := ExpandFileName(Directory) {full absolute path};
  125. if TableLevel <= 0 then
  126. NewDBF.TableLevel := 4 {default to DBase IV}
  127. else
  128. NewDBF.TableLevel := TableLevel;
  129. NewDBF.TableName := 'employee.dbf';
  130. writeln('Creating ', NewDBF.TableName, ' with table level ', NewDBF.TableLevel);
  131. if TableLevel >= 30 {Visual FoxPro} then
  132. begin
  133. NewDBF.FieldDefs.Add('EMP_NO', ftAutoInc);
  134. end
  135. else
  136. NewDBF.FieldDefs.Add('EMP_NO', ftInteger);
  137. NewDBF.FieldDefs.Add('FIRST_NAME', ftString, 15);
  138. NewDBF.FieldDefs.Add('LAST_NAME', ftString, 20);
  139. NewDBF.FieldDefs.Add('PHONE_EXT', ftString, 4);
  140. NewDBF.FieldDefs.Add('JOB_CODE', ftString, 5);
  141. NewDBF.FieldDefs.Add('JOB_GRADE', ftInteger);
  142. NewDBF.FieldDefs.Add('JOB_COUNTR', ftString, 15); //Note 10 character limit for table/field names in most DBases
  143. NewDBF.FieldDefs.Add('SALARY', ftFloat);
  144. NewDBF.CreateTable;
  145. NewDBF.Open;
  146. for i := 1 to 5 do //keep size manageable until we have working files
  147. begin
  148. NewDBF.Append;
  149. if (NewDBF.FieldDefs.Find('EMP_NO').DataType <> ftAutoInc) then
  150. NewDBF.FieldByName('EMP_NO').AsInteger := i;
  151. case i of
  152. 1:
  153. begin
  154. NewDBF.FieldByName('FIRST_NAME').AsString := 'William';
  155. NewDBF.FieldByName('LAST_NAME').AsString := 'Shatner';
  156. NewDBF.FieldByName('PHONE_EXT').AsString := '1702';
  157. NewDBF.FieldByName('JOB_CODE').AsString := 'CEO';
  158. NewDBF.FieldByName('JOB_GRADE').AsInteger := 1;
  159. NewDBF.FieldByName('JOB_COUNTR').AsString := 'USA';
  160. NewDBF.FieldByName('SALARY').AsFloat := 48000;
  161. end;
  162. 2:
  163. begin
  164. NewDBF.FieldByName('FIRST_NAME').AsString := 'Ivan';
  165. NewDBF.FieldByName('LAST_NAME').AsString := 'Ishenin';
  166. NewDBF.FieldByName('PHONE_EXT').AsString := '9802';
  167. NewDBF.FieldByName('JOB_CODE').AsString := 'Eng';
  168. NewDBF.FieldByName('JOB_GRADE').AsInteger := 2;
  169. NewDBF.FieldByName('JOB_COUNTR').AsString := 'Russia';
  170. NewDBF.FieldByName('SALARY').AsFloat := 38000;
  171. end;
  172. 3:
  173. begin
  174. NewDBF.FieldByName('FIRST_NAME').AsString := 'Erin';
  175. NewDBF.FieldByName('LAST_NAME').AsString := 'Powell';
  176. NewDBF.FieldByName('PHONE_EXT').AsString := '1703';
  177. NewDBF.FieldByName('JOB_CODE').AsString := 'Admin';
  178. NewDBF.FieldByName('JOB_GRADE').AsInteger := 2;
  179. NewDBF.FieldByName('JOB_COUNTR').AsString := 'USA';
  180. NewDBF.FieldByName('SALARY').AsFloat := 45368;
  181. end;
  182. 4:
  183. begin
  184. NewDBF.FieldByName('FIRST_NAME').AsString := 'Margaret';
  185. NewDBF.FieldByName('LAST_NAME').AsString := 'Tetchy';
  186. NewDBF.FieldByName('PHONE_EXT').AsString := '3804';
  187. NewDBF.FieldByName('JOB_CODE').AsString := 'Eng';
  188. NewDBF.FieldByName('JOB_GRADE').AsInteger := 3;
  189. NewDBF.FieldByName('JOB_COUNTR').AsString := 'England';
  190. NewDBF.FieldByName('SALARY').AsFloat := 28045;
  191. end;
  192. 5:
  193. begin
  194. NewDBF.FieldByName('FIRST_NAME').AsString := 'Sergey';
  195. NewDBF.FieldByName('LAST_NAME').AsString := 'Bron';
  196. NewDBF.FieldByName('PHONE_EXT').AsString := '3807';
  197. NewDBF.FieldByName('JOB_CODE').AsString := 'Admin';
  198. NewDBF.FieldByName('JOB_GRADE').AsInteger := 3;
  199. NewDBF.FieldByName('JOB_COUNTR').AsString := 'England';
  200. NewDBF.FieldByName('SALARY').AsFloat := 24468;
  201. end;
  202. end;
  203. NewDBF.Post;
  204. end;
  205. NewDBF.Close;
  206. finally
  207. NewDBF.Free;
  208. end;
  209. end;
  210. // Gets list of all .dbf files in a directory and its subdirectories.
  211. procedure GetDBFList(Results: TStringList);
  212. var
  213. r: TSearchRec;
  214. begin
  215. results.Clear;
  216. if FindFirst('*.dbf', faAnyFile - faDirectory -
  217. {$WARNINGS OFF}
  218. faVolumeID - faSymLink
  219. {$WARNINGS ON}
  220. , r) = 0 then
  221. begin
  222. repeat
  223. begin
  224. results.add(expandfilename(r.Name));
  225. end;
  226. until (FindNext(r) <> 0);
  227. findclose(r);
  228. end;
  229. end;
  230. // Convert binary field contents to strings with hexadecimal representation.
  231. // Useful for displaying binary field contents.
  232. function BinFieldToHex(BinarySource: TField): string;
  233. var
  234. HexValue: PChar;
  235. begin
  236. Result := '';
  237. HexValue := StrAlloc(Length(BinarySource.AsBytes));
  238. try
  239. try
  240. BinToHex(PChar(BinarySource.AsBytes), HexValue, Length(BinarySource.AsBytes));
  241. Result := 'size: ' + IntToStr(Length(BinarySource.AsBytes)) + '; hex: ' + HexValue;
  242. except
  243. on E: Exception do
  244. begin
  245. Result := 'exception: ' + E.ClassName + '/' + E.Message;
  246. end;
  247. end;
  248. finally
  249. StrDispose(HexValue);
  250. end;
  251. end;
  252. // Writes contents of available records to screen
  253. procedure PrintRecords(DBf: TDBf);
  254. var
  255. i: integer;
  256. RecordCount: integer;
  257. begin
  258. Dbf.First;
  259. RecordCount:=0;
  260. while not (Dbf.EOF) do
  261. begin
  262. RecordCount := RecordCount + 1;
  263. writeln('Record ' + IntToStr(RecordCount));
  264. for i := 0 to DBf.Fields.Count - 1 do
  265. begin
  266. if DBF.fields[i].IsNull then
  267. writeln('Field ', DBf.Fields[i].FieldName, ' is ***NULL***')
  268. else
  269. if DBF.Fields[i].DataType in [ftVarBytes, ftBytes] then
  270. writeln('Field ', DBF.Fields[i].FieldName, ' has value: binary ' + BinFieldToHex(DBF.Fields[i]))
  271. else
  272. writeln('Field ', DBf.Fields[i].FieldName, ' has value: ' + DBf.fields[i].AsString);
  273. end;
  274. DBF.Next;
  275. writeln('');
  276. end;
  277. end;
  278. { TDBFTool }
  279. procedure TDBFTool.ExportDBF(var MyDbf: TDbf; ExportFormat: string);
  280. var
  281. ExportSettings: TCustomExportFormatSettings;
  282. Exporter: TCustomFileExporter;
  283. begin
  284. try
  285. case UpperCase(ExportFormat) of
  286. 'ACCESS', 'MSACCESS':
  287. begin
  288. Exporter := TXMLXSDExporter.Create(nil);
  289. ExportSettings := TXMLXSDFormatSettings.Create(true);
  290. (ExportSettings as TXMLXSDFormatSettings).CreateXSD := true;
  291. (ExportSettings as TXMLXSDFormatSettings).ExportFormat :=
  292. AccessCompatible;
  293. (ExportSettings as TXMLXSDFormatSettings).DecimalSeparator := '.';
  294. Exporter.FileName := MyDBF.FilePathFull + ChangeFileExt(MyDBF.TableName, '.xml');
  295. end;
  296. 'ADO', 'ADONET', 'ADO.NET':
  297. begin
  298. Exporter := TXMLXSDExporter.Create(nil);
  299. ExportSettings := TXMLXSDFormatSettings.Create(true);
  300. (ExportSettings as TXMLXSDFormatSettings).CreateXSD := true;
  301. (ExportSettings as TXMLXSDFormatSettings).ExportFormat :=
  302. ADONETCompatible;
  303. (ExportSettings as TXMLXSDFormatSettings).DecimalSeparator := '.';
  304. Exporter.FileName := MyDBF.FilePathFull + ChangeFileExt(MyDBF.TableName, '.xml');
  305. end;
  306. 'CSVEXCEL', 'EXCELCSV', 'CREATIVYST':
  307. begin
  308. Exporter := TCSVExporter.Create(nil);
  309. ExportSettings := TCSVFormatSettings.Create(true);
  310. (ExportSettings as TCSVFormatSettings).RowDelimiter:=LineEnding;
  311. //todo: delimiter?
  312. Exporter.FileName := MyDBF.FilePathFull + ChangeFileExt(MyDBF.TableName, '.csv');
  313. end;
  314. 'CSV', 'CSVRFC4180', 'CSVLIBRE', 'CSVLIBREOFFICE', 'CSVOPENOFFICE':
  315. begin
  316. Exporter := TCSVExporter.Create(nil);
  317. ExportSettings := TCSVFormatSettings.Create(true);
  318. (ExportSettings as TCSVFormatSettings).DecimalSeparator := '.';
  319. (ExportSettings as TCSVFormatSettings).StringQuoteChar := '"';
  320. Exporter.FileName := MyDBF.FilePathFull + ChangeFileExt(MyDBF.TableName, '.csv');
  321. end;
  322. 'DATASET', 'DELPHI':
  323. begin
  324. Exporter := TXMLXSDExporter.Create(nil);
  325. ExportSettings := TXMLXSDFormatSettings.Create(true);
  326. (ExportSettings as TXMLXSDFormatSettings).ExportFormat :=
  327. DelphiClientDataset;
  328. (ExportSettings as TXMLXSDFormatSettings).DecimalSeparator := '.';
  329. Exporter.FileName := MyDBF.FilePathFull + ChangeFileExt(MyDBF.TableName, '.xml');
  330. end;
  331. 'EXCEL', 'EXCELXML':
  332. begin
  333. Exporter := TXMLXSDExporter.Create(nil);
  334. ExportSettings := TXMLXSDFormatSettings.Create(true);
  335. (ExportSettings as TXMLXSDFormatSettings).ExportFormat := ExcelCompatible;
  336. (ExportSettings as TXMLXSDFormatSettings).DecimalSeparator := '.';
  337. Exporter.FileName := MyDBF.FilePathFull + ChangeFileExt(MyDBF.TableName, '.xml');
  338. end;
  339. 'JSON':
  340. begin
  341. Exporter := TSimpleJSONExporter.Create(nil);
  342. ExportSettings := TSimpleJSONFormatSettings.Create(true);
  343. Exporter.FileName := MyDBF.FilePathFull + ChangeFileExt(MyDBF.TableName, '.json');
  344. end;
  345. 'SIMPLEXML', 'XML':
  346. begin
  347. Exporter := TSimpleXMLExporter.Create(nil);
  348. ExportSettings := TSimpleXMLFormatSettings.Create(true);
  349. Exporter.FileName := MyDBF.FilePathFull + ChangeFileExt(MyDBF.TableName, '.xml');
  350. end;
  351. 'RTF':
  352. begin
  353. Exporter := TRTFExporter.Create(nil);
  354. ExportSettings := TSimpleXMLFormatSettings.Create(true);
  355. Exporter.FileName := MyDBF.FilePathFull + ChangeFileExt(MyDBF.TableName, '.rtf');
  356. end;
  357. 'SQL':
  358. begin
  359. Exporter := TSQLExporter.Create(nil);
  360. ExportSettings := TSQLFormatSettings.Create(true);
  361. (ExportSettings as TSQLFormatSettings).QuoteChar := '"';
  362. (ExportSettings as TSQLFormatSettings).DecimalSeparator := '.';
  363. (ExportSettings as TSQLFormatSettings).TableName := ChangeFileExt(MyDBF.TableName,'');
  364. (ExportSettings as TSQLFormatSettings).DateFormat := 'yyyy"-"mm"-"dd'; //ISO 8601, yyyy-mm-dd
  365. (ExportSettings as TSQLFormatSettings).TimeFormat := 'hh":"nn":"ss'; //ISO 8601, hh:mm:ss;
  366. (ExportSettings as TSQLFormatSettings).DateTimeFormat :=
  367. (ExportSettings as TSQLFormatSettings).DateFormat + '"T"' + (ExportSettings as TSQLFormatSettings).TimeFormat; //ISO 8601
  368. Exporter.FileName := MyDBF.FilePathFull + ChangeFileExt(MyDBF.TableName, '.sql');
  369. end;
  370. 'TEX', 'LATEX':
  371. begin
  372. Exporter := TTeXExporter.Create(nil);
  373. ExportSettings := TTeXExportFormatSettings.Create(true);
  374. Exporter.FileName := MyDBF.FilePathFull + ChangeFileExt(MyDBF.TableName, '.tex');
  375. end;
  376. 'TEXT', 'FIXED', 'FIXEDTEXT':
  377. begin
  378. Exporter := TFixedLengthExporter.Create(nil);
  379. ExportSettings := nil;
  380. Exporter.FileName := MyDBF.FilePathFull + ChangeFileExt(MyDBF.TableName, '.txt');
  381. end
  382. else
  383. begin
  384. writeln('***Error: Unknown export format ' + ExportFormat + ' specified' + '. Aborting');
  385. Exporter := nil;
  386. ExportSettings := nil;
  387. Terminate;
  388. Exit;
  389. end;
  390. end;
  391. if assigned(ExportSettings) then
  392. Exporter.FormatSettings := ExportSettings;
  393. Exporter.Dataset := MyDBF;
  394. MyDBF.First; // we've just read the last record - make sure export starts at beginning
  395. Exporter.Execute;
  396. writeln('Completed export to ' + Exporter.FileName);
  397. finally
  398. if assigned(Exporter) then
  399. Exporter.Free;
  400. if assigned(ExportSettings) then
  401. ExportSettings.Free;
  402. end;
  403. end;
  404. function TDBFTool.GetExeName: string;
  405. begin
  406. result := ExtractFileName(ExeName);
  407. end;
  408. procedure TDBFTool.DoRun;
  409. var
  410. DBFs: TStringList;
  411. Demo: boolean;
  412. ErrorMsg: string;
  413. FileNo: integer;
  414. MyDbf: TDbf;
  415. TableLevel: integer;
  416. begin
  417. // quick check parameters
  418. ErrorMsg := CheckOptions('h', 'createdemo exportformat: help tablelevel:');
  419. if ErrorMsg <> '' then
  420. begin
  421. ShowException(Exception.Create(ErrorMsg));
  422. Terminate;
  423. Exit;
  424. end;
  425. // parse parameters
  426. if HasOption('h', 'help') then
  427. begin
  428. WriteHelp;
  429. Terminate;
  430. Exit;
  431. end;
  432. DBFs := TStringList.Create;
  433. try
  434. Demo := false;
  435. if HasOption('createdemo') then
  436. Demo := true;
  437. TableLevel := 4; //DBF
  438. if HasOption('tablelevel') then
  439. TableLevel := StrToIntDef(GetOptionValue('tablelevel'), 4);
  440. if Demo then
  441. begin
  442. try
  443. CreateDemoDBFs('', TableLevel);
  444. except
  445. on E: Exception do
  446. begin
  447. writeln('*** Error creating demo databases: ' + E.Message);
  448. Terminate;
  449. Exit;
  450. end;
  451. end;
  452. end;
  453. // Process all dbfs if no files specified
  454. if DBFs.Count = 0 then
  455. GetDBFList(DBFs);
  456. if DBFs.Count = 0 then
  457. begin
  458. writeln('Could not find any dbf files.');
  459. writeln('Use ' + GetExeName + ' --createdemo to create some test DBF files.');
  460. end;
  461. for FileNo := 0 to DBFs.Count - 1 do
  462. begin
  463. if not (fileexists(DBFs[FileNo])) then
  464. begin
  465. writeln('Sorry, file ',DBFs[FileNo],' does not exist. Ignoring it.');
  466. continue;
  467. end;
  468. MyDbf := TDbf.Create(nil);
  469. try
  470. try
  471. MyDbf.FilePath := ExtractFilePath(DBFs[FileNo]);
  472. MyDbf.TableName := ExtractFileName(DBFs[FileNo]);
  473. MyDbf.ReadOnly := true;
  474. writeln('*** Opening: ' + DBFs[FileNo]);
  475. MyDbf.Open;
  476. writeln('Database tablelevel: ' + IntToStr(MyDbf.TableLevel));
  477. writeln('Database codepage: ' + IntToStr(MyDBF.CodePage));
  478. PrintRecords(MyDBF);
  479. if HasOption('exportformat') then
  480. begin
  481. try
  482. ExportDBF(MyDbf,GetOptionValue('exportformat'));
  483. except
  484. on E: Exception do
  485. begin
  486. writeln('*** Problem exporting file ', FileNo, ': ', E.Message);
  487. end;
  488. end;
  489. end;
  490. MyDbf.Close;
  491. except
  492. on E: Exception do
  493. begin
  494. writeln('*** Error reading file ', FileNo, ': ', E.Message);
  495. end;
  496. end;
  497. finally
  498. MyDbf.Free;
  499. end;
  500. end;
  501. finally
  502. DBFs.Free;
  503. end;
  504. // stop program loop
  505. Terminate;
  506. end;
  507. constructor TDBFTool.Create(TheOwner: TComponent);
  508. begin
  509. inherited Create(TheOwner);
  510. StopOnException := true;
  511. end;
  512. destructor TDBFTool.Destroy;
  513. begin
  514. inherited Destroy;
  515. end;
  516. procedure TDBFTool.WriteHelp;
  517. begin
  518. writeln('Usage: ', GetExeName, ' -h');
  519. writeln(' --createdemo create demo database');
  520. writeln(' --tablelevel=<n> optional: desired tablelevel for demo db');
  521. writeln(' 3 DBase III');
  522. writeln(' 4 DBase IV (default if no tablelevel given)');
  523. writeln(' 7 Visual DBase 7');
  524. writeln(' 25 FoxPro 2.x');
  525. writeln(' 30 Visual FoxPro');
  526. writeln(' --exportformat=<text> export dbfs to format. Format can be:');
  527. writeln(' access Microsoft Access XML');
  528. writeln(' adonet ADO.Net dataset XML');
  529. writeln(' csvexcel Excel/Creativyst format CSV text file (with locale dependent output)');
  530. writeln(' csvRFC4180 LibreOffice/RFC4180 format CSV text file');
  531. writeln(' dataset Delphi dataset XML');
  532. writeln(' excel Microsoft Excel XML');
  533. writeln(' fixedtext Fixed length text file');
  534. writeln(' json JSON file');
  535. writeln(' rtf Rich Text Format');
  536. writeln(' simplexml Simple XML');
  537. writeln(' sql SQL insert statements');
  538. writeln(' tex LaTeX file');
  539. end;
  540. var
  541. Application: TDBFTool;
  542. begin
  543. Application := TDBFTool.Create(nil);
  544. Application.Title := 'DBFTool';
  545. Application.Run;
  546. Application.Free;
  547. end.