Hy everybody,<br><br>I'm trying to use the TFileStream class to read a file with a record, and I obtain this message when I execute my application : Access violation. You can find my code in the following :<br><br>type<br>
DmatLine= record<br> ID1: string;<br> ID2: string;<br> C: integer;//classe différence 1 if reactions aren't of same classe and 0, on the contrary.<br> Euclide: double;//Euclidian distance between two reactions.<br>
Tanimoto: double;//Tanimoto coefficient between two reactions.<br> Dice: double;//Dice coefficient between two reactions.<br> end;<br><br>....<br><br>procedure TReadDmat.ReadDmat(input: string; nbCpd : integer);<br>
var<br> i, j, k, l, m, sizeOfArray, test: integer;<br> DmatFile: TFileStream;<br> LineRecord1, LineRecord2: DmatLine;<br>begin<br> if (FileExists(input) )then<br> begin<br> DmatFile:=TFileStream.Create(input, fmOpenRead);<br>
try<br> DmatFile.Position := 0; <br> while (DmatFile.position < DmatFile.size) {NB ^ see above..} do<br> begin<br> with LineRecord1 do<br> begin<br>
DmatFile.Read(ID1, sizeOf(string));<br> DmatFile.Read(ID2, sizeOf(string));<br> DmatFile.Read(C, sizeOf(integer));<br> DmatFile.Read(Euclide, sizeOf(float));<br>
DmatFile.Read(Tanimoto, sizeOf(float));<br> DmatFile.Read(Dice, sizeOf(float));<br><br> end;<br> writeln(FloatToStr(DmatFile.size));<br><br> finally<br>
DmatFile.free;<br> writeln('toto');<br> end;<br> end else begin<br> writeln('ERROR: File '+input+' does not exist');<br> halt;<br> end;<br>
<br>end;<br><br>I don't undestand nor what it append and nor how use this information once I could read it. <br><br>My file is very big, so, I need use stream and to do some calculations because to do two boucles on my file isn't possible when I use AssignFile and reset.<br>
<br>If you have some tutorials or concils please, it could be help me. I searched on net, on lazarus wiki and documentation and mailing list, but I didn't find what I need.<br><br>Thank you for your help, <br><br>Cheers,<br>
<br>Aurélie de LUCA.<br>