Adding a variable

Top  Previous  Next

Variables can be added only after a category has already been added. All the variables located in the list after a category are considered belonging to that category. Variable names must be unique within the whole list and not just 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 doesn't already exist) or changes the value of an 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, so it is added to the last category. If a variable is to be added at a specific position in 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 a specific 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);