FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour FastReport, variables from PRG in FR3 file
Posts: 208
Joined: Wed Dec 03, 2008 04:48 PM
FastReport, variables from PRG in FR3 file
Posted: Wed Apr 09, 2014 07:48 PM
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 (fw): Select all Collapse
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?
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: FastReport, variables from PRG in FR3 file
Posted: Wed Apr 09, 2014 09:24 PM
Boris,
I use following code:

Code (fw): Select all Collapse
   cZeitRaum := dtoc(anfang) + " - " + dtoc(ende   )
      oFr:AddVariable( "Report", "Zeitraum"       , "'" + cZeitRaum   +"'" )

Best regards,
Otto
Posts: 2064
Joined: Fri Jan 06, 2006 09:28 PM
Re: FastReport, variables from PRG in FR3 file
Posted: Thu Apr 10, 2014 03:40 AM

Tambien puedes usar cValToChar(tu_var_num), saludos... :shock:

Dios no está muerto...



Gracias a mi Dios ante todo!
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: FastReport, variables from PRG in FR3 file
Posted: Thu Apr 10, 2014 06:16 AM

Hi codemaker,

Just add +CRLF to your variable.

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 208
Joined: Wed Dec 03, 2008 04:48 PM
Re: FastReport, variables from PRG in FR3 file
Posted: Thu Apr 10, 2014 02:54 PM

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.

Posts: 208
Joined: Wed Dec 03, 2008 04:48 PM
Re: FastReport, variables from PRG in FR3 file
Posted: Sun Apr 13, 2014 08:13 PM
Now I have a problem with the function GetHbVar()

I define a var and it's content i n a PRG

Code (fw): Select all Collapse
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?
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: FastReport, variables from PRG in FR3 file
Posted: Sun Apr 13, 2014 08:28 PM

Hi,

Can you try [EvalMacro('cMyVar')]?

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 474
Joined: Sun Oct 30, 2005 06:37 AM
Re: FastReport, variables from PRG in FR3 file
Posted: Mon Apr 14, 2014 02:24 AM

[GetHbVar('cMyVar')],This works.
Maybe width of the txt cell is not enough.

http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
Posts: 208
Joined: Wed Dec 03, 2008 04:48 PM
Re: FastReport, variables from PRG in FR3 file
Posted: Mon Apr 14, 2014 05:28 PM
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 (fw): Select all Collapse
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
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: FastReport, variables from PRG in FR3 file
Posted: Mon Apr 14, 2014 05:51 PM

Hi,

if you define variable PRIVATE, can you delete it temporarly?

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 208
Joined: Wed Dec 03, 2008 04:48 PM
Re: FastReport, variables from PRG in FR3 file
Posted: Mon Apr 14, 2014 06:31 PM

Sorry, I am not sure I understand what you mean?

Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: FastReport, variables from PRG in FR3 file
Posted: Mon Apr 14, 2014 07:36 PM

for example.

PRIVATE cMyVar or LOCAL cMyVar

delete this line. if there is.

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 208
Joined: Wed Dec 03, 2008 04:48 PM
Re: FastReport, variables from PRG in FR3 file
Posted: Mon Apr 14, 2014 07:50 PM
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
Posts: 474
Joined: Sun Oct 30, 2005 06:37 AM
Re: FastReport, variables from PRG in FR3 file
Posted: Tue Apr 15, 2014 04:52 AM

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

http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
Posts: 208
Joined: Wed Dec 03, 2008 04:48 PM
Re: FastReport, variables from PRG in FR3 file
Posted: Tue Apr 15, 2014 08:31 PM

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.