FastReport, variables from PRG in FR3 file

User avatar
codemaker
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

FastReport, variables from PRG in FR3 file

Post 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:
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
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: FastReport, variables from PRG in FR3 file

Post by Otto »

Boris,
I use following code:

Code: Select all

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

 
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
User avatar
joseluisysturiz
Posts: 2024
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela
Contact:

Re: FastReport, variables from PRG in FR3 file

Post by joseluisysturiz »

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

Gracias a mi Dios ante todo!
Horizon
Posts: 997
Joined: Fri May 23, 2008 1:33 pm

Re: FastReport, variables from PRG in FR3 file

Post by Horizon »

Hi codemaker,

Just add +CRLF to your variable.
Regards,

Hakan ONEMLI

Harbour & VS 2019 & FWH 20.12
User avatar
codemaker
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: FastReport, variables from PRG in FR3 file

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

Re: FastReport, variables from PRG in FR3 file

Post 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?
Horizon
Posts: 997
Joined: Fri May 23, 2008 1:33 pm

Re: FastReport, variables from PRG in FR3 file

Post by Horizon »

Hi,

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

Hakan ONEMLI

Harbour & VS 2019 & FWH 20.12
ShumingWang
Posts: 454
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Re: FastReport, variables from PRG in FR3 file

Post by ShumingWang »

[GetHbVar('cMyVar')],This works.
Maybe width of the txt cell is not enough.
User avatar
codemaker
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: FastReport, variables from PRG in FR3 file

Post 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
Horizon
Posts: 997
Joined: Fri May 23, 2008 1:33 pm

Re: FastReport, variables from PRG in FR3 file

Post by Horizon »

Hi,

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

Hakan ONEMLI

Harbour & VS 2019 & FWH 20.12
User avatar
codemaker
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: FastReport, variables from PRG in FR3 file

Post by codemaker »

Sorry, I am not sure I understand what you mean?
Horizon
Posts: 997
Joined: Fri May 23, 2008 1:33 pm

Re: FastReport, variables from PRG in FR3 file

Post by Horizon »

for example.

PRIVATE cMyVar or LOCAL cMyVar

delete this line. if there is.
Regards,

Hakan ONEMLI

Harbour & VS 2019 & FWH 20.12
User avatar
codemaker
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: FastReport, variables from PRG in FR3 file

Post by codemaker »

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
ShumingWang
Posts: 454
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Re: FastReport, variables from PRG in FR3 file

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

Re: FastReport, variables from PRG in FR3 file

Post 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.
Post Reply