[fpc-devel]Weird isn't it ?

Maly maly at zga.pl
Wed Feb 12 18:51:58 CET 2003


Hi,

i wrote some unit to handle my own FS :> but that's not
important. well, i've got a constructor looking like this:

constructor CFile.Create(var AFS:CDataFile;APath:string);
 var SavedPath : string;
 begin
  FFS:=AFS;
  SavedPath:=AFS.GetCurrentPath;
//  Writeln(SavedPath);
  FFileName:=CopyUntilReversed(APath,'/');
  FFilePath:=APath;
  AFS.ChDir(FFilePath);
  FIndex:=AFS.GetFileID(FFileName);
  if FIndex=0 then
   raise EDataFileException.Create('file '+APath+'doesn''t exist');
  if FFS.Header.Files[FIndex].IsCompressed then
   DataStream:=TDataFileCompressedStream.Create(FFS,FIndex)
  else
   DataStream:=TDataFileStream.Create(AFS,FIndex);
  FFS.ChDir(SavedPath);
 end;

this code is 100% correct, but in some specific circumstances
it works buggy, the variables(class's fields) have weird
values(like 0 or ''). when I uncomment the commented line
the results are ok. so how's that possible a writeln can
fix the code? it does only print the 'debug-info' :>? it
shouldn't change anything. the point is i don't need that
line infact i don't want it at all. :/
i guess it has something to do with optimiser.
i even triedthe latest snapshot from cvs - it didnt work out.

Help Plz :>.

Best Regards,
Luke 'Maly' O.






More information about the fpc-devel mailing list