如何在有类型文件中实现对相关信息的查询?

解决方案 »

  1.   

    Moves the current position of a file to a specified component. UnitSystemCategoryI/O routinesprocedure Seek(var F; N: Longint);DescriptionUse Seek to move to a specified position in open typed or untyped files. The current file position of F moves to component number N. The number of the first component of a file is 0.In the above syntax, F is a typed or untyped file variable. The file specified by F must be open. N is an expression of type LongintTo expand a file, seek one component beyond the last component; that is, the statement Seek(F, FileSize(F)) moves the current file position to the end of the file.Note: {$I+} handles run-time errors using exceptions. When using {$I-}, use IOResult to check for I/O errors.
      

  2.   

    再用EOF构成循环,一个一个判断Tests whether the file position is at the end of a file.UnitSystemCategoryI/O routinesTyped or untyped files:function Eof(var F): Boolean;Text files:function Eof [ (var F: Text) ]: Boolean;DescriptionEof tests whether the current file position is the end-of-file. F is a file variable. If F is omitted, the standard file variable Input is assumed. Eof(F) returns True if the current file position is beyond the last character of the file or if the file is empty; otherwise, Eof(F) returns False.