Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Sometimes oldschool pascal stylee is not that bad. Even though non-oo file access doesn't seem to be very popular anymore, <code>ReadLn(F,xxx)</code> still works pretty ok in situations like yours.</p> <p>The code below loads information (filename, source and version) into a <code>TDictionary</code> so that you can look it up easily, or you can use a listview in virtual mode, and look stuff up in this list when the <code>ondata</code> even fires.</p> <p>Warning: code below does not work with unicode.</p> <pre><code>program Project101; {$APPTYPE CONSOLE} uses IoUtils, Generics.Collections, SysUtils; type TFileInfo=record FileName, Source, Version:String; end; function LoadFileInfo(var aFileInfo:TFileInfo):Boolean; var F:TextFile; begin Result := False; AssignFile(F,aFileInfo.FileName); {$I-} Reset(F); {$I+} if IOResult = 0 then begin ReadLn(F,aFileInfo.Source); ReadLn(F,aFileInfo.Version); CloseFile(F); Exit(True) end else WriteLn('Could not open ', aFileInfo.FileName); end; var FileInfo:TFileInfo; Files:TDictionary&lt;string,TFileInfo&gt;; S:String; begin Files := TDictionary&lt;string,TFileInfo&gt;.Create; try for S in TDirectory.GetFiles('h:\WINDOWS\system32','*.xml') do begin WriteLn(S); FileInfo.FileName := S; if LoadFileInfo(FileInfo) then Files.Add(S,FileInfo); end; // showing file information... for FileInfo in Files.Values do WriteLn(FileInfo.Source, ' ',FileInfo.Version); finally Files.Free end; WriteLn; WriteLn('Done. Press any key to quit . . .'); ReadLn; end. </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload