Page 1 of 2
FastReport, variables from PRG in FR3 file
Posted: Wed Apr 09, 2014 7:48 pm
by codemaker
I have a report which uses FR3 file and prints ok without problem.
The problem arises when I try to use some variable from PRG i FR3 file
I can use NUMERIC variable from PRG and show it in FR3
But when I want to use STRING variable, the report crashes.
Code: Select all
cCompanyName := ALLTRIM(vcompany->TITLE)
private m_fr := frreportmanager():new()
// x = ALIAS()
// n = SELECT()
m_fr:SetWorkArea(x,n) //"xreport", n)
// Now to define which FIELDS we want to show on the report
m_fr:SetFieldAliases(x, "NAME;SSN;DATEENTER;TOTALH;TOTALL;TOTALB;BALANCEH;PAIDH;DEPARTMENT") // DEPARTMENT is only needed if we sort by DEPARTMENT
m_fr:LoadFromFile(m_pj)
m_fr:AddVariable( "MyVars", "CoName", " ' cCompanyName ' " )
//m_fr:AddVariable( "MyVars", "CoName", " ' " + cCompanyName +" ' " )
//m_fr:AddVariable( "MyVars", "CoName", cCompanyName )
m_fr:DesignReport()
m_fr:DestroyFR()
return nil
None of the above AddVAriable() works
When I drag and drop the variable "coName" the system recognizes the content but shows this error message:
As you see the company name is recognized, but some error triggers and I cannot find the problem...
If I use NUMERIC it shows perfect
Any idea?
Re: FastReport, variables from PRG in FR3 file
Posted: Wed Apr 09, 2014 9:24 pm
by Otto
Boris,
I use following code:
Code: Select all
cZeitRaum := dtoc(anfang) + " - " + dtoc(ende )
oFr:AddVariable( "Report", "Zeitraum" , "'" + cZeitRaum +"'" )
Best regards,
Otto
Re: FastReport, variables from PRG in FR3 file
Posted: Thu Apr 10, 2014 3:40 am
by joseluisysturiz
Tambien puedes usar cValToChar(tu_var_num), saludos...
Re: FastReport, variables from PRG in FR3 file
Posted: Thu Apr 10, 2014 6:16 am
by Horizon
Hi codemaker,
Just add +CRLF to your variable.
Re: FastReport, variables from PRG in FR3 file
Posted: Thu Apr 10, 2014 2:54 pm
by codemaker
Thanks Horizon!
You saved me a lot of night hours....
Works perfect!
FR is an excellent tool but requires a lot of work to get deep into it.
Re: FastReport, variables from PRG in FR3 file
Posted: Sun Apr 13, 2014 8:13 pm
by codemaker
Now I have a problem with the function GetHbVar()
I define a var and it's content i n a PRG
Code: Select all
PRIVATE cMyVar
IF p == 1
cMyVar := "It is ONE"
ELSE
cMyVar := "It is TWO"
ENDIF
In Designer m_fr:DesignReport()
I use text field and put this into it:
[GetHbVar(cMyVar)]
or
[GetHbVar('cMyVar')]
neither works
What am I doing wrong?
Re: FastReport, variables from PRG in FR3 file
Posted: Sun Apr 13, 2014 8:28 pm
by Horizon
Hi,
Can you try [EvalMacro('cMyVar')]?
Re: FastReport, variables from PRG in FR3 file
Posted: Mon Apr 14, 2014 2:24 am
by ShumingWang
[GetHbVar('cMyVar')],This works.
Maybe width of the txt cell is not enough.
Re: FastReport, variables from PRG in FR3 file
Posted: Mon Apr 14, 2014 5:28 pm
by codemaker
Thany to both of you for trying to help.
Neither method suggested works for me
Is there some specifric position of the variable defined and assigned in a program?
I test this way:
Code: Select all
ccLastLine := "AAAAAAAAAAA" //cLastLine
// ccLastLine+= CRLF
// If we need to design!!
//--------------------------
m_fr:LoadFromFile(m_pj)
m_fr:DesignReport()
m_fr:DestroyFR()
return nil
//-----------------------------
// End of design part!!!
It's like the variable is of wrong format or something....
And in Designer I just add this:
[GetHbVar('ccLastLine')]
or
[GetHbVar(ccLastLine)]
neither works....
The field is long enogh for testing "AAAAAAAAAAA" value
Re: FastReport, variables from PRG in FR3 file
Posted: Mon Apr 14, 2014 5:51 pm
by Horizon
Hi,
if you define variable PRIVATE, can you delete it temporarly?
Re: FastReport, variables from PRG in FR3 file
Posted: Mon Apr 14, 2014 6:31 pm
by codemaker
Sorry, I am not sure I understand what you mean?
Re: FastReport, variables from PRG in FR3 file
Posted: Mon Apr 14, 2014 7:36 pm
by Horizon
for example.
PRIVATE cMyVar or LOCAL cMyVar
delete this line. if there is.
Re: FastReport, variables from PRG in FR3 file
Posted: Mon Apr 14, 2014 7:50 pm
by codemaker
Unfortunatelly same problem...
If I enter into text field on FR3:
[GetHbVar('cclastLine')]
the error is this
If I enter into text field on FR3 :
[GetHbVar(cclastLine)]
the error is this
Re: FastReport, variables from PRG in FR3 file
Posted: Tue Apr 15, 2014 4:52 am
by ShumingWang
function test()
local FrPrn
private cmyvar
cmyvar:="aaaa"
FrPrn := frReportManager():new()
frprn:designReport()
FrPrn:DestroyFR()
return
// fr3 design ,add a text cell (A) , [getHBvar('cmyvar')]
preview result: aaaa
Re: FastReport, variables from PRG in FR3 file
Posted: Tue Apr 15, 2014 8:31 pm
by codemaker
The problem I discovered tonight is:
1. If I start a new report and have it blank at the beginning, I can do [GetHbVar('ccLastLine')] anywhere on the blank report inside the Text field and it shows the content opf the variable
2. If I already have some report designed, I cannot put the [GetHbVar('ccLastLine')] in any band or anywhere on the report without an error.
Don't know why.
For now I have to put this aside, have to continue working with FR on some reports.
I just found out how to use groups and group footers to have some group records summed and so forth.
FR is a good tool but requires some work to get into all its features and use it with success.