home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 294.lha / TurboFile / Demos / structure.mod < prev    next >
Encoding:
Text File  |  1989-10-09  |  1.5 KB  |  69 lines

  1. MODULE STRUCTURE;
  2.  
  3. (*
  4.           Written by Dexter (Chip) Orange  October, 1989.
  5.  
  6.      I'm afraid this is a rather hastily thrown together demo to give you
  7. some assistance in using the dBASE module of the TurboFile system.  What it
  8. does is to print out the structure of a dBASE database.
  9.  
  10.  
  11. *)
  12.  
  13.  
  14. FROM dBASE IMPORT
  15.   dBASEHeaderRec, Use, DataRecordPtr;
  16. FROM RandomIO IMPORT
  17.   RandomFile, CloseRandomFile, RandomFileMode;
  18. FROM InOut IMPORT
  19.   Write, WriteString, WriteLn, ReadString, WriteCard;
  20.  
  21.  
  22.  
  23. VAR
  24.   FN: ARRAY [0..80] OF CHAR;
  25.   F: RandomFile;
  26.   I,N, RL, TOTAL: CARDINAL;
  27.   H: dBASEHeaderRec;
  28.   DR: DataRecordPtr;
  29.  
  30.  
  31.  
  32. BEGIN
  33.   TOTAL := 0;
  34.   WriteString('enter dBASE file name');
  35.   ReadString(FN);
  36.   WriteLn;
  37.   DR := DataRecordPtr(1);
  38.                         (* KEEP USE FROM ALLOCATING ONE *)
  39.   IF (Use(FN, H, F, ReadOnly,  N, RL, 0, DR)) THEN
  40.     WriteString(' record size is ');
  41.     WriteCard(RL, 3);
  42.     WriteLn;
  43.     FOR I := 1 TO N DO
  44.       WITH H DO
  45.         WITH FieldList[I] DO
  46.           WriteCard(I, 2);
  47.           Write(' ');
  48.           WriteString(FieldName);
  49.           Write(' ');
  50.           Write(FieldType);
  51.           Write(' ');
  52.           WriteCard(CARDINAL(FieldLength), 3);
  53.           Write(' ');
  54.           WriteLn;
  55.           TOTAL := TOTAL+CARDINAL(FieldLength);
  56.         END;
  57.      (* WITH FIELDLIST *)
  58.       END;
  59.      (* WITH H *)
  60.     END;
  61.      (* FOR *)
  62.     WriteString(' ** total ** ');
  63.     WriteCard(TOTAL,3);
  64.     WriteLn;
  65.     CloseRandomFile(F);
  66.   END;
  67.      (* IF *)
  68. END STRUCTURE.
  69.