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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T22:00:50+00:00 2026-06-18T22:00:50+00:00

I have such file: file of record Str: string[250]; RecType: Cardinal; end; but after

  • 0

I have such file:

file of record
  Str: string[250];
  RecType: Cardinal;
end;

but after some time using of this file my customer found, that Str never be bigger than 100 chars and also he need additional fields.

In new version we have such file:

file of packed record
  Str: string[200];
  Reserved: array[1..47] of Byte;
  NewFiled: Cardinal;
  RecType: Cardinal;
end;

This record have the same size, in previous record between Str and RecType was one unused byte when aligned to 8 bytes.

Question: what happened, when this new file will be readed from old code? He need backward compatability.

Old code reading sample:

var
  FS: TFileStream;
  Rec: record
         Str: string[250];
         RecType: Cardinal;
       end;
...
// reading record by record from file:
FS.Read(Rec, SizeOf(Rec));
  • 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-18T22:00:51+00:00Added an answer on June 18, 2026 at 10:00 pm

    The old school pascal string use the first byte of the string (index 0) to store the length of the string.

    Let’s look at the memory of this record:

    byte    0  1  2  3  4  5  6  7  8  9 10 11  12  13 ........ 243..246 247..250
    value  10 65 66 67 68 69 70 71 72 73 74  0 200 130          NewField RecType
    

    From byte 11 to 242, the memory can contain garbage, it is simply ignored by the program (never shown) as this takes the value 10 at the byte 0 as the length of the string, so the string becomes 'ABCDEFGHIJ'

    This ensures the old program reading a file created with the most recent version will never see garbage at the end of the strings, since the view of that strings will be limited to the actual size of the string and that memory positions are just ignored.

    You have to double check if the old program does not change the values stored in case it writes the records back to the file. I think it is also safe, but I’m just not sure and have no Delphi at hand to test.

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

Sidebar

Related Questions

I have such file and I would like to replace $GLOBALS['SERVER_MEMCACHED']='localhost'; with $GLOBALS['SERVER_MEMCACHED']='mydomain.com'; using
I have such .htaccess file: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php
I'm new to web development.I have a php file such as addcourse.php.In this file
I have xml file with such structure: ... <outer> ... <inner/> ... </outer> ...
I have a class (Schedule) defined as such (schedule.h file shown) #import <UIKit/UIKit.h> #import
Assuming that I have a typedef declared in my .h file as such: typedef
I have a file with entries such as: 26 1 33 2 . .
I have a JavaScript file which has a variable as such: var ads =
How can I parse a String str = abc, \def,ghi\ ; such that I
I'm using Propel to retrieve a list of products, some of the products have

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.