Hy everybody, 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 :
type DmatLine= record ID1: string; ID2: string; C: integer;//classe différence 1 if reactions aren't of same classe and 0, on the contrary. Euclide: double;//Euclidian distance between two reactions. Tanimoto: double;//Tanimoto coefficient between two reactions. Dice: double;//Dice coefficient between two reactions. end; .... procedure TReadDmat.ReadDmat(input: string; nbCpd : integer); var i, j, k, l, m, sizeOfArray, test: integer; DmatFile: TFileStream; LineRecord1, LineRecord2: DmatLine; begin if (FileExists(input) )then begin DmatFile:=TFileStream.Create(input, fmOpenRead); try DmatFile.Position := 0; while (DmatFile.position < DmatFile.size) {NB ^ see above..} do begin with LineRecord1 do begin DmatFile.Read(ID1, sizeOf(string)); DmatFile.Read(ID2, sizeOf(string)); DmatFile.Read(C, sizeOf(integer)); DmatFile.Read(Euclide, sizeOf(float)); DmatFile.Read(Tanimoto, sizeOf(float)); DmatFile.Read(Dice, sizeOf(float)); end; writeln(FloatToStr(DmatFile.size)); finally DmatFile.free; writeln('toto'); end; end else begin writeln('ERROR: File '+input+' does not exist'); halt; end; end; I don't undestand nor what it append and nor how use this information once I could read it. 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. 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. Thank you for your help, Cheers, Aurélie de LUCA.
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal