Página 1 de 1

Variables from report

Publicado: Jue Nov 20, 2014 11:56 am
por dmajkic
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)Â

Variables from report

Publicado: Jue Nov 20, 2014 7:42 pm
por ignacio
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,

Variables from report

Publicado: Jue Nov 20, 2014 9:46 pm
por dmajkic
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

Variables from report

Publicado: Vie Nov 21, 2014 2:02 pm
por ignacio
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,

Variables from report

Publicado: Vie Nov 21, 2014 7:13 pm
por dmajkic
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/documentatio ... 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/documentatio ... index.html? calling_the_variables_from_the_reports_variables_list.htm

Attached files e2.fr3 (1.7 KB)Â e2.prg (565 B)Â

Variables from report

Publicado: Vie Nov 28, 2014 11:26 am
por dmajkic
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.

Variables from report

Publicado: Vie Nov 28, 2014 2:09 pm
por ignacio
dmajkic escribió el vie, 28 noviembre 2014 11:26This 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,