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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:28:37+00:00 2026-05-15T22:28:37+00:00

In a delphi unit, I have a global record called ‘Context’: interface type TContext

  • 0

In a delphi unit, I have a global record called ‘Context’:

interface
  type
    TContext = record
       ...
    end;

  var
    context: TContext;

I also have a initialization procedure in this unit, taking a context:

interface  
  procedure Init(AContext: TContext);

Inside the Init procedure, I try to assign the given context to the global context:

implementation
  procedure Init(AContext: TContext);
  begin
    context := AContext;
  end;

For some reason, the global context remains empty after the assignment. Why is that?
Declaring a local variable inside the procedure, and assigning to it works as expected.


What I should have mentioned, is that this unit lives in a dll, and the init procedure is called from the exe.
Declaring a global record, or declaring several global strings makes no difference. The assigned values are lost.

regards,
-Vegar

  • 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-15T22:28:38+00:00Added an answer on May 15, 2026 at 10:28 pm

    The error is found. Everything was kind of a mess really…. It turned out that the object responsible for calling the init-method existed twice, and the unit containing the global variable existed both inside the dll and the exe project. For some reason, one of the instances of the calling class manipulated the global variable inside the exe and the other the one inside the dll, and both the developer and the debugger where tripped to a halt…

    The code is part of some old, messy legacy code which we are trying to break apart and clean up. We really start to get the hang of the ‘breaking’-part…

    Thanks for the responses, and sorry for wasting your time.

    regards,
    -Vegar

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

Sidebar

Related Questions

I have added these two methods to the 1st unit of my Delphi 5
I have a unit called RCLowPass which uses Unit2. It uses the object TForm2.
This must be a Delphi bug... I have a unit which is the basis
I have a case in Delphi such as: Unit A contains class One Unit
I have a form called MyForm stored in a unit called Unit UnitMyFrom. Of
I have a Delphi unit that is statically linking a C .obj file using
I have a library of functions contained in a delphi unit which we shall
How to create a Thread Safe global TList ? unit Unit1; interface uses ...;
I have a unit I wrote in Delphi 7 some time ago, and have
I have been assigned the task to refactor a Delphi unit. Wow. 10000 lines

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.