createds.pp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2000 by Michael Van Canneyt, member of the
  4. Free Pascal development team
  5. Creates a flat datafile for use with testds.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. program createds;
  13. {$mode delphi}
  14. uses ddg_rec,sysutils;
  15. Type IndexFile = File Of Longint;
  16. Var F : TDDGDataFile;
  17. I : Integer;
  18. S : String;
  19. L : IndexFile;
  20. TableName : String;
  21. IndexName : String;
  22. ARec : TDDGData;
  23. begin
  24. If ParamCount<>1 then
  25. begin
  26. Writeln('Usage: createds tablename');
  27. Halt(1);
  28. end;
  29. TableName:=ChangeFileExt(paramstr(1),'.ddg');
  30. IndexName:=ChangeFileExt(TableName,'.ddx');
  31. Assign(F,TableName);
  32. Rewrite(F);
  33. For I:=1 to 100 do
  34. begin
  35. S:=Format('This is person %d.',[i]);
  36. With Arec Do
  37. begin
  38. Name:=S;
  39. height:=I*0.001;
  40. LongField:=i*4;
  41. ShoeSize:=I;
  42. WordField:=i*2;
  43. DateTimeField:=Now;
  44. TimeField:=Time;
  45. DateField:=Date;
  46. Even:=(I mod 2) = 0
  47. end;
  48. Write(F,ARec);
  49. end;
  50. Close(F);
  51. Assign(L,IndexName);
  52. Rewrite(L);
  53. For I:=0 to 100-1 do
  54. Write(L,I);
  55. Close(L);
  56. end.