FastReport, variables from PRG in FR3 file

FastReport, variables from PRG in FR3 file

Postby codemaker » Wed Apr 09, 2014 7: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: Select all  Expand view  RUN

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:
Image

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?
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: FastReport, variables from PRG in FR3 file

Postby Otto » Wed Apr 09, 2014 9:24 pm

Boris,
I use following code:

Code: Select all  Expand view  RUN

   cZeitRaum := dtoc(anfang) + " - " + dtoc(ende   )
      oFr:AddVariable( "Report", "Zeitraum"       , "'" + cZeitRaum   +"'" )

 

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6336
Joined: Fri Oct 07, 2005 7:07 pm

Re: FastReport, variables from PRG in FR3 file

Postby joseluisysturiz » Thu Apr 10, 2014 3:40 am

Tambien puedes usar cValToChar(tu_var_num), saludos... :shock:
Dios no está muerto...

Gracias a mi Dios ante todo!
User avatar
joseluisysturiz
 
Posts: 2064
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela

Re: FastReport, variables from PRG in FR3 file

Postby Horizon » Thu Apr 10, 2014 6:16 am

Hi codemaker,

Just add +CRLF to your variable.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: FastReport, variables from PRG in FR3 file

Postby codemaker » Thu Apr 10, 2014 2: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.
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: FastReport, variables from PRG in FR3 file

Postby codemaker » Sun Apr 13, 2014 8:13 pm

Now I have a problem with the function GetHbVar()

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

Code: Select all  Expand view  RUN

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?
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: FastReport, variables from PRG in FR3 file

Postby Horizon » Sun Apr 13, 2014 8:28 pm

Hi,

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

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: FastReport, variables from PRG in FR3 file

Postby ShumingWang » Mon Apr 14, 2014 2: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
ShumingWang
 
Posts: 465
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Re: FastReport, variables from PRG in FR3 file

Postby codemaker » Mon Apr 14, 2014 5: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: Select all  Expand view  RUN

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
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: FastReport, variables from PRG in FR3 file

Postby Horizon » Mon Apr 14, 2014 5:51 pm

Hi,

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

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: FastReport, variables from PRG in FR3 file

Postby codemaker » Mon Apr 14, 2014 6:31 pm

Sorry, I am not sure I understand what you mean?
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: FastReport, variables from PRG in FR3 file

Postby Horizon » Mon Apr 14, 2014 7:36 pm

for example.

PRIVATE cMyVar or LOCAL cMyVar

delete this line. if there is.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: FastReport, variables from PRG in FR3 file

Postby codemaker » Mon Apr 14, 2014 7:50 pm

Unfortunatelly same problem...

If I enter into text field on FR3:
[GetHbVar('cclastLine')]
the error is this
Image

If I enter into text field on FR3 :
[GetHbVar(cclastLine)]
the error is this
Image
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: FastReport, variables from PRG in FR3 file

Postby ShumingWang » Tue Apr 15, 2014 4: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
ShumingWang
 
Posts: 465
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Re: FastReport, variables from PRG in FR3 file

Postby codemaker » Tue Apr 15, 2014 8: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.
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 44 guests