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 888393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:23:24+00:00 2026-05-15T13:23:24+00:00

Question closed (answer accepted) replaced by Delphi 7: Access violation – TByteDynArray problem )

  • 0

Question closed (answer accepted) replaced by Delphi 7: Access violation – TByteDynArray problem)


I have the following delcartion given to me

MyPhoto = class(TRemotable)
private
  FhasPhoto: Boolean;
  FphotoData: TByteDynArray;
published
  property hasPhoto: Boolean read FhasPhoto write FhasPhoto;
  property photoData: TByteDynArray read FphotoData write FphotoData;
end;

and I want to

var photo : MyPhoto;
photo := MyPhoto.Create();
SetLength(photo.photoData, 4);

but I get

[Error] mainForm.pas(340): Constant object cannot be passed as var parameter

1) How do I code it correctly, given that I can’t change the definition of the class Photo?
2) can I effectively ‘cast’ any structure to a TByteDynArray just by assigning it?

(as you might have guessed, I’m a BCB guy trying to get into Ddlphi 🙂


p.s I will settle for being able to assign each byte of the photo data individually…

  • 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-05-15T13:23:25+00:00Added an answer on May 15, 2026 at 1:23 pm

    This is a flaw in Delphi’s implementation of properties. Even if the property can be read and written to, even if both the read and the write point to the same field in the underlying object, you can’t pass a property to a var parameter, such as to SetLength. There’s no good reason for this, but that’s the way it works, for the time being at least.

    There’s a fairly simple workaround for this issue, though. You need a method on the object that takes an integer and will set the length of FPhotoData internally.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 454k
  • Answers 454k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I got a lot of good comments on this question,… May 15, 2026 at 9:43 pm
  • Editorial Team
    Editorial Team added an answer Use hg forget, and then add the generated files to… May 15, 2026 at 9:43 pm
  • Editorial Team
    Editorial Team added an answer Your parameter is incorrect. it needs to be named the… May 15, 2026 at 9:43 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.