testcp.pp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. {
  2. $Id$
  3. This file is part of the Free Component Library (FCL)
  4. Copyright (c) 1999-2000 by the Free Pascal development team
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {$mode objfpc}
  12. {$h+}
  13. program testcp;
  14. uses db,memds,classes,sysutils;
  15. Procedure DoTest;
  16. var
  17. I,ACount : integer;
  18. D : TDateTime;
  19. M1,M2 : TMemDataSet;
  20. begin
  21. M1:=TMemDataset.Create(Nil);
  22. Try
  23. M2:=TMemDataset.Create(Nil);
  24. Try
  25. M1.FileName:=ParamStr(1);
  26. M1.Open;
  27. Writeln('Copying');
  28. M2.CopyFromDataSet(M1);
  29. Writeln('Copied');
  30. With M2 do
  31. begin
  32. First;
  33. ACount:=0;
  34. While Not EOF do
  35. begin
  36. Inc(ACount);
  37. Writeln('Record ',ACount,' : ');
  38. Writeln('------------------------');
  39. For I:=0 to FieldCount-1 do
  40. Writeln(Fields[I].FieldName,' : ',Fields[I].AsString);
  41. Writeln;
  42. Next;
  43. end;
  44. Writeln('Total data size : ',DataSize);
  45. Close;
  46. end;
  47. finally
  48. M2.Free;
  49. end;
  50. finally
  51. M1.Free;
  52. end;
  53. end;
  54. begin
  55. If ParamCount<>1 then
  56. begin
  57. Writeln('Usage : testopen <filename>');
  58. Halt(1);
  59. end;
  60. DoTest;
  61. end.