Adding a variable from BCB6
BJL
Brussels, Belgium
BCB6 and FR304
Adding a string variable from the BCB code gives the error:
Impossible to convert 'char*' to 'int'.
How to add a variable?
frxReport1->Variables["EXERCICE"] = StringVariable; // error
with no single quote between the double quotes:
frxReport1->Variables["EXERCICE"] = "" + StringVariable + ""; // error
with one single quote between the double quotes:
frxReport1->Variables["EXERCICE"] = "'" + StringVariable + "'"; // error
with 4 single quote between the double quotes as shown in the programmer's manual:
frxReport1->Variables["EXERCICE"] = "''''" + StringVariable + "''''"; // error
BJL
Adding a string variable from the BCB code gives the error:
Impossible to convert 'char*' to 'int'.
How to add a variable?
frxReport1->Variables["EXERCICE"] = StringVariable; // error
with no single quote between the double quotes:
frxReport1->Variables["EXERCICE"] = "" + StringVariable + ""; // error
with one single quote between the double quotes:
frxReport1->Variables["EXERCICE"] = "'" + StringVariable + "'"; // error
with 4 single quote between the double quotes as shown in the programmer's manual:
frxReport1->Variables["EXERCICE"] = "''''" + StringVariable + "''''"; // error
BJL
Comments
frxReport1->Variables["EXERCICE"] = QuotedStr(StringVariable);
This one should work:
AnsiString StringVariable = "Hello !!!";
int index = frxReport1->Variables->IndexOf("EXERCICE");
if(index >= 0)
{
frxReport1->Variables->Items[index]->Value = QuotedStr(StringVariable);
}
See other message "Variable in MemoView, ";" expected".
BJL
Report.Variables:= 'abc'; // error
Report.Variables.Items[1].Value:= 'abc'; // error
But, I use following code, it is ok:
procedure TfrmMain.frxReport1GetValue(const VarName: String;
var Value: Variant);
begin
if VarName='Date1' then
Value:= FormatDateTime('yyy-mm-dd', dtp1.Date)
else if VarName='Date2' then
Value:= FormatDateTime('yyy-mm-dd', dtp2.Date)
else;
end;