testpop.pp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. {
  2. This file is part of the Free Component Library (FCL)
  3. Copyright (c) 1999-2000 by the Free Pascal development team
  4. See the file COPYING.FPC, included in this distribution,
  5. for details about the copyright.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. **********************************************************************}
  10. {$mode objfpc}
  11. {$h+}
  12. program testpop;
  13. uses db,memds,classes,sysutils;
  14. Procedure DoTest;
  15. var
  16. I,ACount : integer;
  17. D : TDateTime;
  18. begin
  19. with TMemDataset.Create(Nil) do
  20. Try
  21. With FieldDefs do
  22. begin
  23. Clear;
  24. Add('Boolean', ftBoolean, 0, False);
  25. Add('Integer', ftInteger, 0, False);
  26. Add('SmallInt', ftSmallInt, 0, False);
  27. Add('Float', ftFloat, 0, False);
  28. Add('String', ftString, 30, False);
  29. Add('Time', ftTime, 0, False);
  30. Add('Date', ftDate, 0, False);
  31. end;
  32. CreateTable;
  33. Open;
  34. D:=now;
  35. ACount:=1000;
  36. for I:=1 to ACount do
  37. begin
  38. Append;
  39. FieldByName('Boolean').AsBoolean:=False;
  40. FieldByName('Integer').AsInteger:=I;
  41. FieldByName('SmallInt').AsInteger:=I;
  42. FieldByName('Float').AsFloat:=I/10;
  43. FieldByName('String').AsString:='Test-Data '+IntToStr(I);
  44. FieldByName('Time').AsDateTime:=D;
  45. FieldByName('Date').AsDateTime:=D;
  46. Post;
  47. end;
  48. First;
  49. ACount:=0;
  50. While Not EOF do
  51. begin
  52. Inc(ACount);
  53. Writeln('Record ',ACount,' : ');
  54. Writeln('------------------------');
  55. For I:=0 to Fields.Count-1 do
  56. Writeln(Fields[I].FieldName,' : ',Fields[I].AsString);
  57. Writeln;
  58. Next;
  59. end;
  60. Writeln('Total data size : ',DataSize);
  61. If (ParamCount>0) then
  62. FileName:=ParamStr(1);
  63. Close;
  64. finally
  65. Free;
  66. end;
  67. end;
  68. begin
  69. DoTest;
  70. end.