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.

AddArray

FastReport for Xailer & [x]Harbour (English/Spanish)
nbatocanin
Posts: 23
Joined: Sat Aug 10, 2013 2:39 am

AddArray

Postby nbatocanin » Wed Nov 19, 2014 2:53 am

I'm trying to add tables to report using AddArray method. This work fine, but i found one problem. When table is empty, then there is no data and method calling is:
oTest := oFr:AddArray ("Test", {}, aStruc)
This call does not add the table in the report. For example, this produces an error:
oTest:SetMaster (...)
User avatar
ignacio
Site Admin
Posts: 8530
Joined: Mon Apr 06, 2015 8:00 pm
Location: Madrid, Spain
Contact:

AddArray

Postby ignacio » Wed Nov 19, 2014 12:10 pm

nbatocanin escribió el mié, 19 noviembre 2014 02:53
I'm trying to add tables to report using AddArray method. This work fine, but i found one problem. When table is empty, then there is no data and method calling is:
oTest := oFr:AddArray ("Test", {}, aStruc)
This call does not add the table in the report. For example, this produces an error:
oTest:SetMaster (...)

Obviously arrays should not be empty. But in any case you should get a valid oTest object. The sturcture of the array data should be equal to aStruc. So an empty array is not valid.
Regards,
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
nbatocanin
Posts: 23
Joined: Sat Aug 10, 2013 2:39 am

AddArray

Postby nbatocanin » Wed Nov 19, 2014 1:43 pm

I think the object is _not_ valid. Please look at the following example:
#include "frh.ch"
PROC Main
oFr := FrReportManager():New()
oFr:Create()
f := {{"t_id", "N", 10, 0}}
a := {}
AAdd (a, {100})
AAdd (a, {200})
AAdd (a, {300})
oA1 := oFr:AddArray ("niz1", a, f)
b := {}
AAdd (b, {100}) // (*)
AAdd (b, {200}) // (*)
f := {{"t_id", "N", 10, 0}} // (**)
oA2 := oFr:AddArray ("niz2", b, f)
oA2:SetMaster (oA1, {"t_id=t_id"})
oFr:DesignReport()
oFr:End()
RETURN

This application works correctly. But, if you delete the (*) lines (table oA2 is empty), receives the error "SetMaster detail - Detail field t_id not found".
BTW, seems to AddArray has a bug. Check the value of F before and after the call AddArray:
before:
f := {{"t_id", "N", 10, 0}}
after:
f := {"t_id", "N", 10, 0}
User avatar
ignacio
Site Admin
Posts: 8530
Joined: Mon Apr 06, 2015 8:00 pm
Location: Madrid, Spain
Contact:

AddArray

Postby ignacio » Wed Nov 19, 2014 2:30 pm

Dear Sir,
Cita:
This application works correctly. But, if you delete the (*) lines (table oA2 is empty), receives the error "SetMaster detail - Detail field t_id not found".

The bug arises because your array structure is not equal to your fields structure. So to say, you can not use empty arrays.
Cita:
after:
f := {"t_id", "N", 10, 0}

The property admits an array of arrays or an array of string with this structure: <name>,<type>,<len>,<dec>. If you use the first method then is converted to an array of string:
f := {"t_id,N, 10, 0"}
If you do not want that to happens send a aClone( f ). BTW, it will be fixed on next release.
Regards,
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
nbatocanin
Posts: 23
Joined: Sat Aug 10, 2013 2:39 am

AddArray

Postby nbatocanin » Wed Nov 19, 2014 3:02 pm

ignacio wrote on Wed, 19 November 2014 14:30
Dear Sir,
Cita:
This application works correctly. But, if you delete the (*) lines (table oA2 is empty), receives the error "SetMaster detail - Detail field t_id not found".

The bug arises because your array structure is not equal to your fields structure. So to say, you can not use empty arrays.

I think it's a bit illogical, but ok. If I want to add a table via AddArray, I suppose I must add a "phantom empty record" when table is empty?

Return to “FastReport”