Changed From Fr2.x to 4
Hi,
I use/used Borland Builder C++ 6 with fast reports 2.x and have set everything up using variables and accessing them in my
c++ code as such:
AnsiString cert = QuotedStr("Certification #123456");
AnsiString contract=QuotedStr("Contract AV1234");
frReport1->Dictionary->Variables->Variable["Cert"]=cert;
frReport1->Dictionary->Variables->Variable["ContractNumber"]=contract;
frReport1->PrepareReport();
frReport1->ShowReport();
and all works fine in bcb6
Im now using codegear's radstudio 2007 with Fast Reports 4
and Im am converting the reports over and I am having trouble with the variables.
I did the conversion from frf to fr3 by adding the delphi use frx2xto30.
Converting the reports over has gone fairly well..
The variables made it over and all.
The code in radgear does not compile using
frReport1->Dictionary
so I converted it to
frReport1->Variables->Variable["Cert"]=cert;
frReport1->Variables->Variable["ContractNumber"]=contract;
and it compiles, runs and the value even is getting set because later after printing I added code
to check the values and they are set to what I set them too...but
the MemoViews are empty of the variable value.
I modified the one that shows [Cert] to Certificate Number: [Cert]
and the only part that shows is Certificate Number:
I also used
int index=frxReport1->Variables->IndexOf("Cert");
if (index>=0) {
frxReport1->Variables->Variables[index]=cert;
}
What am I doing wrong here?
I use/used Borland Builder C++ 6 with fast reports 2.x and have set everything up using variables and accessing them in my
c++ code as such:
AnsiString cert = QuotedStr("Certification #123456");
AnsiString contract=QuotedStr("Contract AV1234");
frReport1->Dictionary->Variables->Variable["Cert"]=cert;
frReport1->Dictionary->Variables->Variable["ContractNumber"]=contract;
frReport1->PrepareReport();
frReport1->ShowReport();
and all works fine in bcb6
Im now using codegear's radstudio 2007 with Fast Reports 4
and Im am converting the reports over and I am having trouble with the variables.
I did the conversion from frf to fr3 by adding the delphi use frx2xto30.
Converting the reports over has gone fairly well..
The variables made it over and all.
The code in radgear does not compile using
frReport1->Dictionary
so I converted it to
frReport1->Variables->Variable["Cert"]=cert;
frReport1->Variables->Variable["ContractNumber"]=contract;
and it compiles, runs and the value even is getting set because later after printing I added code
to check the values and they are set to what I set them too...but
the MemoViews are empty of the variable value.
I modified the one that shows [Cert] to Certificate Number: [Cert]
and the only part that shows is Certificate Number:
I also used
int index=frxReport1->Variables->IndexOf("Cert");
if (index>=0) {
frxReport1->Variables->Variables[index]=cert;
}
What am I doing wrong here?
Comments
I guess no one knows any C++ or the correct way to set a variable from within my application.
So I wrote my own function to do this...though I would rather just know the proper way to get a variable to display.
For anyone else that is using C++ and wants to make a variable visible heres what I did:
it assumes you use [ and ] as the delimiters for a variable.
set them with
Contract and Certificate are AnsiString's that contain the value wanted for the variables.
Cert and ContractNumber are the Variable names defined in the fr3 file.
SetVariable(frxReport1,"Cert",Certificate);
SetVariable(frxReport1,"ContractNumber",Contract);
void __fastcall TfrmPrint::SetVariable(TfrxReport * report,AnsiString Variable,AnsiString Value)
{
AnsiString var=AnsiString("[") + Variable + AnsiString("]");
int x=report->ComponentCount;
int z=0;
while(x)
{
TfrxMemoView * ms= dynamic_cast<TfrxMemoView*>(report->Components[z]);
if (ms)
{
AnsiString txt=ms->Text;
int variablepos=txt.AnsiPos(var);
int varlen=var.Length();
if (variablepos>0)
{
AnsiString u=ms->Text;
if (LowerCase(u)==LowerCase(var))
{
ms->Text=Value;
}
else
{
AnsiString u=txt.SubString(1,variablepos-1);
u+=Value;
u+=txt.SubString(variablepos+varlen,txt.Length());
ms->Text=u;
}
}
}
x--;
z++;
}
}