Kromster
Kromster

Reputation: 7397

How to pass array of string into a FastReport variable?

My plan is to pass an array of string into a FastReport

Here's my code (stripped from all irrelevant parts and error handling):

var
  elements: TStringArray; // TStringArray = array of string;
begin
  FR := TfrxReport.Create(Self);
  FR.LoadFromFile(...);
  FR.Variables['dataArray'] := elements; // <-- Error here
  FR.ShowReport;
  FR.Free;
end;

But I get the error, indicating that I can not assign an array to a string that way:

Could not convert variant of type (array OleStr) into type String

However if I assign '['a', 'b', 'c', 'd', 'e', 'f']' to a dataArray variable within FastReport editor it works just fine - I can access dataArray[1] and etc.

So my question is - How to properly assign a variable of type array of string to FastReport variable?

Upvotes: 1

Views: 6275

Answers (1)

Andy_D
Andy_D

Reputation: 2350

I don't have a copy of FastReport to hand, but I know it uses an internal copy of FastScript. If you can gain access to this you should be able to make the Delphi variable available to the script using the script's AddVariable method. e.g.

FR.Script.AddVariable('elements', 'Array', elements);

Upvotes: 3

Related Questions