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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:20:17+00:00 2026-05-23T18:20:17+00:00

I have 2 records like this: TYPE TRecord2= packed record i2: Integer; end; TRecord1=

  • 0

I have 2 records like this:

TYPE
 TRecord2= packed record
  i2: Integer;
 end;

 TRecord1= packed record
  i1: Integer;
  R2: TRecord2;
 end;

.

I want to initialize the record fields to zero but I don’t want to use FillMemory so I declared 2 constant records in which I initialize the fields.

CONST
  Record2c: TRecord2=
  (
   i2: 0;
  );

  Record1c: TRecord1=
  (
    i1: 0;
    R2: Record2c;      <------- error line
  );

However, I cannot assign a Record2c to R2 field. The compiler says: E2029 ‘(‘ expected but identifier ‘Record2c’ found.

But this works (if I comment the line where I have the error):

procedure test;
var Record1: TRecord1;
begin
 Record1:= Record1c;      // initialize variable by associating the constant to it
end

So, how do i initialize the R2 field?

  • 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-23T18:20:17+00:00Added an answer on May 23, 2026 at 6:20 pm

    You can only initialize consts with true constants. True constants do not have types — those are typed constants. See Declared Constants in the Delphi documentation. Record2c in your code is a typed constant, so it cannot be used in const expressions like the one required for initializing Record1c. You’ll just have to in-line the definition of Record1c.R2:

    const
      Record1c: TRecord1 = (
        i1: 0;
        R2: (i2: 0;);
      );
    

    When you comment out the error line, you’re leaving the R2 field default-initialized to zeros.

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

Sidebar

Related Questions

I have some XML which contains records and sub records, like this: <data> <record
In my Oracle db I have records like this one: <ROOT> <Event> <Type>sldkfvjhkljh</Type> <ID>591252</ID>
I have an XML document which looks something like this: <meadinkent> <record> <comp_div>MENSWEAR</comp_div> <sty_ret_type>ACCESSORIES</sty_ret_type>
I have some records like this: ID Personel_Code Time --- ------------- ------ 1 0011
I have a collection of MODS records that looks like this: <modsCollection> <mods [namespaces
I have a table where a record looks like this varchar(255) Name varchar(255) Text
I have a an XSD that looks like this (roughly) <xs:schema id=Appointment targetNamespace=http://tempuri.org/Record.xsd elementFormDefault=qualified
I have a List of an Record(structure) like this : struct Rec { int
I have a records in my table Test like this my Date column is
I have a table with 8 million records that looks like this: CREATE TABLE

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.