In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

Variables from report

FastReport for Xailer & [x]Harbour (English/Spanish)
dmajkic
Posts: 21
Joined: Wed Sep 24, 2014 12:48 pm

Variables from report

Postby dmajkic » Thu Nov 20, 2014 11:56 am

I looks like I can't get FastReport Varibale value.
I set variable, and display it in report, but I am unable to get it'value from PRG.
I need access to Variables from bOnBtnSendMail to perform my own Mail send to using HB sending engine which supports GMail.
Please find attached ultra-simple example. It should print "NEW VALUE", but it doesn't do that.


Attached files e2.fr3 (1.5 KB)Â e2.prg (522 B)Â
User avatar
ignacio
Site Admin
Posts: 8529
Joined: Mon Apr 06, 2015 8:00 pm
Location: Madrid, Spain
Contact:

Variables from report

Postby ignacio » Thu Nov 20, 2014 7:42 pm

Hello,
The variable is inaccessible due two reasons:
1) Is not intialized when you first retrieve its value. The variable does not get any value until is started (printed).
I believe FR designer does not let you change any variable value. So you should set its value at least once by code.
BTW, that is what we do with Xailer:
   ::DeleteCategory('Xailer')
::AddCategory('Xailer')
::AddVariable('Application:cCompany', Application:cCompany )
::AddVariable('Application:cCopyright', Application:cCopyright )
::AddVariable('Application:cDescription', Application:cDescription )
::AddVariable('Application:cDirectory', Application:cDirectory )
::AddVariable('Application:cFilename', Application:cFilename )
::AddVariable('Application:cTitle', Application:cTitle )
::AddVariable('Application:cVersion', Application:cVersion )

Maybe you can do something similar to that.
2) FR uses the underscore to distinguish between categories and variables. So, do not put them.
This code worked on my side:
oRep:OnBtnGenPdf := {|o| MsgInfo(:GetVariable( "Test" )), .t. }
Regards,
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
dmajkic
Posts: 21
Joined: Wed Sep 24, 2014 12:48 pm

Variables from report

Postby dmajkic » Thu Nov 20, 2014 9:46 pm

Quote:
I believe FR designer does not let you change any variable value

You can create and set variables via designer (click on Report->Variables...), or via script using Set() and Get() functions.
If you look at the bottom of the image, you can see what I am trying to do: Create Dialog, and return variable M.OK='TRUE' to harbour program.
Quote:
oRep:OnBtnGenPdf := {|o| MsgInfo(:GetVariable( "Test" )), .t. }

I cant retreive value set in report dialog. I always get value set in prg.


Attached files
User avatar
ignacio
Site Admin
Posts: 8529
Joined: Mon Apr 06, 2015 8:00 pm
Location: Madrid, Spain
Contact:

Variables from report

Postby ignacio » Fri Nov 21, 2014 2:02 pm

Cita:
You can create and set variables via designer

SET via designer????? I could not find how, Please explain. BTW your _TEST variable was not initialized.
Cita:
or via script using Set() and Get() functions.

The variable DOES NOT RECEIVE A VALUE UNTIL THE REPORT IS STARTED. WHEN YOU RETRIEVE THE VAR VALUE YOUR SCRIPT IS NOT RUNNED YET. It worked for me because I retrieve the var value on the OnBtnPdf event.
Cita:
I cant retreive value set in report dialog. I always get value set in prg.

You do not need to create, nor to set its value, if already exists on your fr3 file.
Regards,
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
dmajkic
Posts: 21
Joined: Wed Sep 24, 2014 12:48 pm

Variables from report

Postby dmajkic » Fri Nov 21, 2014 7:13 pm

Quote:
The variable DOES NOT RECEIVE A VALUE UNTIL THE REPORT IS STARTED.

No need to yell.
I initialize variable TEST in report designer.
Then on report create I change value (in PascalScript) to "NEW VALUE". That "NEW VALUE" is displayed on the report preview.
I would like to retrieve that "NEW VALUE" to Harbour app.
To do that I set block on bOnSendMail which uses GetVariable(), and simple print to screen.
I have a preview and "NEW VALUE" on screen.
Then I clik on Export->Email...
Retrieved value is not "NEW VALUE", but old value set in designer.
Attached is, perhaps a bit better, example without underscore on TEST, which demonstrates what I wrote.
Quote:
SET via designer????? I could not find how, Please explain.

Here is the official manual. Creating and initializatiing of variables via designer:
http://www.fast-report.com/documentation/UserMan/index.html? calling_the_variables_from_the_reports_variables_list.htm
Here is the official manual. Creating and initializatiing of variables via designer:
http://www.fast-report.com/documentation/UserMan/index.html? calling_the_variables_from_the_reports_variables_list.htm

Attached files e2.fr3 (1.7 KB)Â e2.prg (565 B)Â
dmajkic
Posts: 21
Joined: Wed Sep 24, 2014 12:48 pm

Variables from report

Postby dmajkic » Fri Nov 28, 2014 11:26 am

This issue remains in new FRX version.
Just for reminder, when example above is compiled and started:
* Report is shown with "NEW VALUE" displayed on report preview
* Click on Export->Email...
* This should print on terminal "NEW VALUE", but it doesn't (instead prints old value)
It looks like report values are not retreived from FR Report object, but from some kind of
internal FRX cache which is not updated after creation.
User avatar
ignacio
Site Admin
Posts: 8529
Joined: Mon Apr 06, 2015 8:00 pm
Location: Madrid, Spain
Contact:

Variables from report

Postby ignacio » Fri Nov 28, 2014 2:09 pm

dmajkic escribió el vie, 28 noviembre 2014 11:26
This issue remains in new FRX version.
Just for reminder, when example above is compiled and started:
* Report is shown with "NEW VALUE" displayed on report preview
* Click on Export->Email...
* This should print on terminal "NEW VALUE", but it doesn't (instead prints old value)
It looks like report values are not retreived from FR Report object, but from some kind of
internal FRX cache which is not updated after creation.

This code is working fine here:
   WITH OBJECT TFastReport():New()
:Create()
:cFilename := ".Reportse2.fr3"
MsgInfo(:GetVariable( "Test" ))
:OnBtnGenPdf := {|o| MsgInfo(:GetVariable( "Test" )), .t. }
:DesignReport()
:End()
END WITH

Regards,
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info

Return to “FastReport”