Accessing data stored in another unit Delphi

Posted by Hendriksen123 on Stack Overflow See other posts from Stack Overflow or by Hendriksen123
Published on 2010-04-13T15:01:46Z Indexed on 2010/04/13 15:23 UTC
Read the original article Hit count: 407

In Unit2 of my program i have the following code:

TValue = Record
  NewValue,
  OldValue,
  SavedValue : Double;
end; 

TData = Class(TObject)
Public
  EconomicGrowth : TValue;
  Inflation : TValue;
  Unemployment : TValue;
  CurrentAccountPosition : TValue;
  AggregateSupply : TValue;
  AggregateDemand : TValue;
  ADGovernmentSpending : TValue;
  ADConsumption : TValue;
  ADInvestment : TValue;
  ADNetExports : TValue;
  OverallTaxation : TValue;
  GovernmentSpending : TValue;
  InterestRates : TValue;
  IncomeTax : TValue;
  Benefits : TValue;
  TrainingEducationSpending : TValue;
End;

I then declare Data : TData in the Var.

when i try to do the following however in Unit1:

  ShowMessage(FloatToStr(Unit2.Data.Inflation.SavedValue));

I get an EAccessViolation message. Is there any way to access the data stored in 'Data' from Unit1 without getting errors?

© Stack Overflow or respective owner

Related posts about delphi

Related posts about data-structures