Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Problem with records and TStream.

arash82arash82 Member Posts: 106
Hi,

I have created a record somthing like this:
[code]
...
type
TData = Record
Name: WideString;
Age: Byte;
end;
var
Data: TData;
FixupInfo: Integer;
...
[/code]

then I use a TStream to write the info:

[code]
...
Data.Name := 'Arash';
...
Stream.WriteResourceHeader('Data', FixupInfo);
Stream.WriteBuffer(Data, SizeOf(Header));
Stream.FixupResourceHeader(FixupInfo);
Stream.SaveToFile(FileName');
...
[/code]

Later when i try to load the file after a reboot the procedure fails. I use this one:

[code]
...
var
ImageSize: Integer;
begin
with Stream do
begin
ReadResHeader;
Position := Position - 4;
ReadBuffer(ImageSize, SizeOf(Longint));
ReadBuffer(Data, ImageSize);
ShowMessage(Data.Name);
...
[/code]

This doesn't work. Why?

Comments

  • Chris BrownChris Brown USAMember Posts: 4,624 ✭✭

    ______ [ http://forcoder.org ] free video tutorials and ebooks about ( Objective-C Delphi Ruby R Visual Basic .NET C# MATLAB C++ Python PL/SQL Swift Perl Assembly PHP Go Java Scratch Visual Basic JavaScript C Erlang Prolog Clojure Logo Crystal FoxPro Hack Alice LabVIEW Scala Awk ML Lua Dart D Fortran Bash Ada Julia SAS F# ABAP Kotlin Scheme Lisp Rust Apex VBScript Transact-SQL COBOL ) _____________

Sign In or Register to comment.