testcp.pp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 testcp;
  13. uses db,memds,classes,sysutils;
  14. Procedure DoTest;
  15. var
  16. I,ACount : integer;
  17. D : TDateTime;
  18. M1,M2 : TMemDataSet;
  19. begin
  20. M1:=TMemDataset.Create(Nil);
  21. Try
  22. M2:=TMemDataset.Create(Nil);
  23. Try
  24. M1.FileName:=ParamStr(1);
  25. M1.Open;
  26. Writeln('Copying');
  27. M2.CopyFromDataSet(M1);
  28. Writeln('Copied');
  29. With M2 do
  30. begin
  31. First;
  32. ACount:=0;
  33. While Not EOF do
  34. begin
  35. Inc(ACount);
  36. Writeln('Record ',ACount,' : ');
  37. Writeln('------------------------');
  38. For I:=0 to FieldCount-1 do
  39. Writeln(Fields[I].FieldName,' : ',Fields[I].AsString);
  40. Writeln;
  41. Next;
  42. end;
  43. Writeln('Total data size : ',DataSize);
  44. Close;
  45. end;
  46. finally
  47. M2.Free;
  48. end;
  49. finally
  50. M1.Free;
  51. end;
  52. end;
  53. begin
  54. If ParamCount<>1 then
  55. begin
  56. Writeln('Usage : testopen <filename>');
  57. Halt(1);
  58. end;
  59. DoTest;
  60. end.