Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9247753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:48:45+00:00 2026-06-18T09:48:45+00:00

I am trying to move a project from D6 to D-XE3. I am getting

  • 0

I am trying to move a project from D6 to D-XE3. I am getting garbage when saving and loading the tree data in the OnSaveNode and OnLoadEvents using version 5.10 of VirtualStringTree. I’m probably not handling Unicode correctly, but there could be some other ignorance on my part:

procedure TfMain.vstGridSaveNode(Sender: TBaseVirtualTree; Node: PVirtualNode;
  Stream: TStream);
var
  Data: PStkData;
begin
  Data := Sender.GetNodeData(Node);

  //  Owned: boolean;
  Stream.Write(Data.Owned, SizeOf(boolean) );

  //  Symbol: string;
  Stream.Write(PChar(Data.Symbol)^, Length(Data.Symbol) * SizeOf(Char));

  //  AvgTarget: currency;
  //Stream.Write(Data.AvgTarget, SizeOf(currency));

  //  PE: double;
  Stream.Write(Data.PE, SizeOf(double));
end;

procedure TfMain.vstGridLoadNode(Sender: TBaseVirtualTree; Node: PVirtualNode;
  Stream: TStream);
var
  Data: PStkData;
begin
  Data := Sender.GetNodeData(Node);

  //Owned: boolean;
  Stream.Read(Data.Owned, SizeOf(boolean));

  //Symbol: string;
  Stream.Read(PChar(Data.Symbol)^, Length(Data.Symbol) * SizeOf(Char));

  //AvgTarget: currency;
  Stream.Read(Data.AvgTarget, SizeOf(currency));

  //PE: double;
  Stream.Read(Data.PE, SizeOf(double));
end;

Thanks for any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:48:46+00:00Added an answer on June 18, 2026 at 9:48 am

    When you write the character data, you need to make sure you write it in such a way that you know how much to read again while loading. You’re currently writing just the character data, so you have no idea how much you need to read again later. You’re instead assuming that Symbol will already be the right length, which, now that I’ve pointed it out, is something you probably realize is an invalid assumption.

    When you write the string, first write its length so it will be available to read while loading:

    var
      SymbolLen: Integer;
    
    SymbolLen := Length(Data.Symbol);
    Stream.Write(SymbolLen, SizeOf(SymbolLen));
    Stream.Write(PChar(Data.Symbol)^, Length(Data.Symbol) * SizeOf(Data.Symbol[1]));
    

    Then you can read it:

    Stream.Read(SymbolLen, SizeOf(SymbolLen));
    SetLength(Data.Symbol, SymbolLen);
    Stream.Read(PChar(Data.Symbol)^, SymbolLen * SizeOf(Data.Symbol[1]));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to move project which was using MySQL database to the one
Trying to move some code from an MVC3 project to an MVC4 project, and
Im trying to move data from one table to another because the needs of
I am trying to move my project from cakephp 1.3 to cakephp 2.x. I
I'm trying to move our project over to VS2008 from VS2005 and am running
I'm trying to move a project over to using Entity Framework, but to make
Finally reached data migration part of my Project and now trying to move data
Trying to move a Qt 4.6.3 project from Windows to Debian Linux (Etch). I've
I'm trying to move a directory (trunk/project/subproject) from a repository rep_a to a newly
I'm trying to use aspnet_compiler to move a project that has already compiled from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.