Adding a variable
Variables can be added only after a category is already added. All the variables located in the list after the category, are considered belonging to this category. Variables’ names must be unique within the whole list, and not within a category
There are several ways to add a variable to the list:
Pascal:
frxReport1.Variables['My Variable 1'] := 10;
C++:
frxReport1->Variables->Variables["My Variable 1"] = 10;
this way adds a variable (if it does not exist already) or modifies a value of the existing variable.
Pascal:
var
Variable: TfrxVariable;
Variable := frxReport1.Variables.Add;
Variable.Name := 'My Variable 1';
Variable.Value := 10;
C++:
TfrxVariable * Variable;
Variable = frxReport1->Variables->Add();
Variable->Name = "My Variable 1";
Variable->Value = 10;
Both of the ways add a variable to the end of the list, therefore, it would be added to the last category. If a variable is supposed to be added to a specified position of the list, use the “Insert” method:
Pascal:
var
Variable: TfrxVariable;
Variable := frxReport1.Variables.Insert(1);
Variable.Name := 'My Variable 1';
Variable.Value := 10;
C++:
TfrxVariable * Variable;
Variable = frxReport1->Variables->Insert(1);
Variable->Name = "My Variable 1";
Variable->Value = 10;
If a variable is to be added to the specified category, use the AddVariable
method:
Pascal:
frxReport1.Variables.AddVariable('My Category 1', 'My Variable 2', 10);
C++:
frxReport1->Variables->AddVariable("My Category 1", "My Variable 2", 10);