Can you post your real code? Your current LoadFromStream()
and SaveToStream()
appear to be testing routines because they contain syntax errors and, in their current form, do not make sense:
In LoadFromStream()
you load your data into a local variable myRec
. After that, your procedure ends and myRec
is gone. You can inspect myRec
in the debugger, but in the end, this method accomplishes nothing.
"Real code" would, for example, take an instance of TMyrecord
and a filename as parameters for LoadFromStream()
and SaveToStream()
Thank you , i don't have an issue with
LoadFromStream()
and
SaveToStream()
, because i'll use my Rec else where , my issue now is with updating MyRec value then save it again ( at same stream position ) . thank you again
Delphi-Quellcode:
procedure UpdateMyRecLastName(NewLastName:string);
var
LoadingStream: TFileStream;
i, j: Integer;
myRec:Tmyrecord;
begin
SavingStream := TFileStream.Create('SAVE.test', fmCreate or fmOpenWrite or fmShareDenyWrite);
try
myRec.LastName := ReadStringFromStream(SavingStream); // load the OLD value
myRec.LastName:=NewLastName; // update it
{
Here how to update myRec.LastName value in the LoadingStream
}
finally
SavingStream.Free;
end;
end;