home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 294.lha / TurboFile / sequentialio.def < prev   
Text File  |  1989-10-09  |  3KB  |  106 lines

  1. DEFINITION MODULE SequentialIO;
  2. (*
  3.      Written by Dexter (Chip) Orange, August, 1987.
  4.  
  5. 3227 Rain Valley Ct.
  6. Tallahassee, FL.  32308
  7.  
  8. home: (904) 877-0061
  9. Work: (904) 487-2680
  10. Compuserve: 71450,1162
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.           Copyright (C) 1987, 1989, Dexter (Chip) Orange
  19. All rights reserved.  The modules of the TurboFile system may not be
  20. distributed in any way, nor a discussion of the algorithms used there-in,
  21. without the express written permission of the copyright holder (Dexter
  22. Orange).
  23.  
  24.      This module of the TurboFile system implements routines for doing very
  25.  fast,
  26. I/O on sequential access files.
  27. All I/O is buffered, and the larger the buffer, the faster things will go.
  28.  
  29.  
  30.  
  31.           Version 1.0,  September 1989.
  32. Converted from TDI  to M2Sprint.
  33.  
  34. *)
  35. FROM SYSTEM IMPORT
  36.   BYTE;
  37.  
  38. TYPE
  39.   SequentialFile;
  40. (* You must declare a variable in your program of this type for each
  41. sequential file you wish to use. *)
  42.  
  43.   SequentialFileMode = (SequentialRead, SequentialWrite, NewSequentialFile);
  44. (* SequentialRead is self-explainatory, SequentialWrite will begin appending
  45. to the end of a file if it exists, or create a new one if necessary, and
  46. NewSequentialFile will force the creation of a new file *)
  47.  
  48. VAR
  49.   SIOErrorMessage: ARRAY [0..80] OF CHAR;
  50. (* contains the text of any error message *)
  51.  
  52.  
  53.  
  54.  
  55.  
  56. PROCEDURE OpenSequentialFile (VAR File     : SequentialFile; FileName : ARRAY OF
  57. CHAR; mode         : SequentialFileMode; BufferedBytes: LONGCARD) : BOOLEAN;
  58. (* open (or create) a file for Sequential access. *)
  59. (* returns true if the open is successful *)
  60.  
  61.  
  62. PROCEDURE CloseSequentialFile (File : SequentialFile);
  63. (* Flushes the write buffer (if any) and concludes access to a Sequential file
  64.  *)
  65.  
  66.  
  67.  
  68. PROCEDURE ReadSequentialFile (File     : SequentialFile; VAR data : ARRAY OF
  69. BYTE;                                   (* Any type here *)
  70. BytesToRead: LONGCARD) : BOOLEAN;
  71. (* read a group of bytes from a Sequential file *)
  72. (* returns TRUE if number of bytes specified can be read *)
  73.  
  74.  
  75. PROCEDURE ReadLine (File     : SequentialFile; VAR Data: ARRAY OF CHAR) :
  76. BOOLEAN;
  77. (* read characters from a sequential file until an EOL char is found.
  78. Any characters which won't fit into "Data" are lost. *)
  79. (* returns true if read successful *)
  80.  
  81.  
  82. PROCEDURE WriteSequentialFile (File    : SequentialFile; VAR data : ARRAY OF
  83. BYTE;                                   (* Any type here *)
  84. BytesToWrite: LONGCARD) : BOOLEAN;
  85. (* write a group of bytes to the Sequential file *)
  86. (* returns true if write successful *)
  87.  
  88.  
  89.  
  90. PROCEDURE WriteLine (File    : SequentialFile) : BOOLEAN;
  91. (* write an EOL character to a sequential file *)
  92. (* returns true if the write is successful *)
  93.  
  94.  
  95. PROCEDURE NumBytes(File: SequentialFile) : LONGCARD;
  96. (* return file size *)
  97.  
  98.  
  99. PROCEDURE Rewind(File: SequentialFile);
  100. (* re-position to beginning of file *)
  101.  
  102.  
  103.  
  104.  
  105. END SequentialIO.
  106.