home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / btree / btriev14 / create.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1991-10-27  |  1.9 KB  |  62 lines

  1. PROGRAM Create;              { (C) 1991 John C. Leon   last updated 10/25/91 }
  2.  
  3. {
  4. Creates an empty Btrieve file of record length 30 with 2 keys.  This empty
  5. file is used in EXAMPLE1.PAS, and should be named EXAMPLE (no extension).
  6. }
  7.  
  8. {$IFDEF production} {$D-,R-,L-,S-} {$ENDIF}
  9.  
  10. USES
  11.    BTP;
  12.  
  13. VAR
  14.    Counter,
  15.    Counter1   : integer;
  16.    MyFileSpec : PFileSpec;
  17.    MyFileName : string;
  18.  
  19. BEGIN
  20.   MyFileSpec := new(PFileSpec);
  21.   with MyFileSpec^ do
  22.     begin
  23.       {Create a fixed length, standard Btrieve file, with no pre-allocation  }
  24.       {and no alternate collating sequence.                                  }
  25.       RecLen   :=   30;   FileFlags := 0;
  26.       PageSize :=  512;   PreAlloc  := 0;
  27.       NumKeys  :=    2;
  28.       for Counter := 0 to 23 do                      {These 3 lines MUST be}
  29.          for Counter1 := 1 to 16 do                  {used to zero out the }
  30.             KeyArray[Counter].Entire[Counter1] := 0; {array.  MANDATORY!   }
  31.       {Key #0}
  32.       with KeyArray[0] do
  33.          begin
  34.          KeyPos := 11; KeyLen := 20;
  35.          {recommend ALWAYS using ExtType in KeyFlags assignment}
  36.          KeyFlags := Duplicates + Modifiable + ExtType;
  37.          ExtKeyType:= BString; {always assign a value to this element}
  38.          end;
  39.       {Key #1}
  40.       with KeyArray[1] do
  41.          begin
  42.          KeyPos :=  1; KeyLen := 10;
  43.          KeyFlags := Duplicates + Modifiable + ExtType;
  44.          ExtKeyType := BString;
  45.          end;
  46.     end; {with MyFileSpec^ do}
  47.  
  48.   write('Enter name of file to create: ');
  49.   readln(MyFileName);
  50.   BStatus := CreateFile(MyFileName, MyFileSpec);
  51.   dispose(MyFileSpec);
  52.   if BStatus <> 0 then
  53.     writeln('Error creating file.  Status = ', BStatus)
  54.     else
  55.     begin
  56.     for Counter := 1 to length(MyFileName) do
  57.        MyFileName[Counter] := upcase(MyFileName[Counter]);
  58.     writeln('File ', MyFileName, ' created successfully.');
  59.     end;
  60.  
  61. END.
  62.