Welcome! Log In Create A New Profile

Advanced

Problem printing array - WinDev22

Posted by gga 
gga
Problem printing array - WinDev22
February 06, 2019 06:36AM
I am trying to print an array using the report writer. I have checked the array and it is all correct but when I print the report it prints the the first record in the array repeatedly for the entire array. i.e.it is not stepping through the array but the number of lines is correct.
I have used this approach before and it has always worked. The only difference is that this time the array is an array of structures.
Do you have any clues as to what the cause of this might be?
Garry
Peter Holemans
Re: Problem printing array - WinDev22
February 06, 2019 10:00AM
Hi Garry,

Not sure this is it but are you referring your print variables to the correct array index?
ArrayWithStructures[Index].StructItem

Otherwise you can do the data processing yourself in the data processing section of the report:
FOR EACH StructItem OF ArrayWithStructures
Do the print of StructItem
END

Cheers,

Peter H.
gga
Re: Problem printing array - WinDev22
February 06, 2019 07:52PM
I seem to have found the problem (see attached) but I can't find a place to change it. The Report Editor insists on adding [subscript] to the linked item.
Garry
Attachments:
open | download - ZB_array.png (32.6 KB)
open | download - ZB_array1.png (35.8 KB)
Re: Problem printing array - WinDev22
February 07, 2019 01:43AM
Gag,

Don’t think you can use an array of arrays for databinding. I looked it up in the help and do not see yes or no but looks like no from this view

DW
Re: Problem printing array - WinDev22
February 07, 2019 10:13AM
Hi Gary,

I perfectly can use an array of structures for printing. So it IS possible.

It looks like you have defined oCount:m_arrBenchSheet[1] as the data source of your report.
You most probably need m_arrBenchSheet as the complete array, but maybe WD is not capabable of that. Because it is a sub-variable of oCount

Can you show us how oCount and m_arrBenchSheet are defined?

Try creating a m_arrBenchSheetTmp as a stand alone array and use that in your report. Of course you need a few lines, just before printing, to copy all data from oCount:m_arrBenchSheet to m_arrBenchSheetTmp

Arie
gga
Re: Problem printing array - WinDev22
February 07, 2019 07:06PM
Hi Arie
oCount is an object of class Count and m_arrBenchSheet is a member
StBench is Structure
sSpecie is string
xFrac is numeric
iCount is int
xDensity is numeric
xMeanLen is numeric
xMeanWt is numeric
xBiomass is numeric
END

m_arrBenchSheet is dynamic array of StBench

I tried moving m_arrBenchSheet out of the class and into a global variable so I could deal with it independently for testing but when I try to link the Report variables to the content of the array it still insists on including [1] in the reference.
See attached pics: ZBLinking1.png is before clicking on sSpecie and ZBLinking2.png is after.
Garry
Attachments:
open | download - ZBLinking1.png (38.6 KB)
open | download - ZBLinking2.png (37.1 KB)
Re: Problem printing array - WinDev22
February 08, 2019 09:11AM
Garry,

that looks pretty much the same as I do here, except that the link is pointing correctly in my case (so without referencing [1])

I do see one difference compared to my definitions (and as said: 'global' and not as a class member)
Try
m_arrBenchSheet is array of StBench
instead of
m_arrBenchSheet is dynamic array of StBench

Arie
gga
Re: Problem printing array - WinDev22
February 08, 2019 04:46PM
I removed 'dynamic' but it didn't change anything so I decided to look at a project where I had done something similar: In that project I had an Invoice object that contained a member m_arrInvLine which was an array based on a structure. As nearly as I can make out the process is identical to my project that doesn't work!
Very frustrating. I have rebooted my machine, recompiled the project, done every synchronization I could think of and it still doesn't work.
As an experiment, I tried linking the report field to a variable in a different array and it behaved identically. It appears that something is subtly corrupted in this project and I don't know where to look.
Garry
Re: Problem printing array - WinDev22
February 08, 2019 05:20PM
Hello Gary,

I have had this issue once. I had a structure that had an array in it and then used it as an array. So it was a nested array inside a array of structure. When I tried to link it I had that same exact thing your images show. So I made the array inside the structure standalone and had no issue. I think in windev you can not nest an array inside another array and then data bind it. I could be wrong but if you are not sure report it to pcsoft

Dennis
gga
Re: Problem printing array - WinDev22
February 08, 2019 06:26PM
Hi Dennis
I think you misunderstood something... I don't have any arrays as part of my structures: I just have an array based on a structure.
Garry
Re: Problem printing array - WinDev22
February 08, 2019 08:11PM
Hello Gary,

"oCount is an object of class Count"

What is oCount how is it declared?

I take it Count is your class that is holding the structure "StBench" and the "m_arrBenchSheet" array


1)Show all of the code of the top of the class declaring your structure and array as is.

2)Show how you are declaring the class in the report.

This would give better perspective on what you are doing.


DW
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: