Página 1 de 1
How do I make REPORT columns to access an array?
Publicado: Jue Jun 06, 2013 11:34 am
por ChrisGillard
I am having trouble understanding how I can use blocks to access array elements in a REPORT column. I think it is my understanding of blocks, binding and technical stuff!
My example code shows a few simple columns and a for/next to make columns that access a parse of a data field. I try to macro compile a block to include the element number 'n' as a string?
I also try to number the column titles
The logdisplay image shows the cBlock .... looks promising.
The output image shows the printed report.
The column titles are all 5 ... my loop is 1 to 4?
The data printed 'File Exported' is the 4th element of the 1st records EVENT string .... but it is printed in all columns and for all records.
Any help would be appreciated, thanks.
Attached files
How do I make REPORT columns to access an array?
Publicado: Jue Jun 06, 2013 5:34 pm
por ignacio
Hello,
nPos := 1
aData := {....}
COLUMN ... DATA aData[1, nPos] ...
COLUMN ... DATA aData[2, nPos] ...
COLUMN ... DATA aData[3, nPos] ...
oReport:bSkip := {|| nPos++ }
oReport:bWhile := {|| nPos <= Len( aData ) }
Regards,
How do I make REPORT columns to access an array?
Publicado: Jue Jun 06, 2013 5:39 pm
por ignacio
BTW,
>> DATA bBlock
That is incorrect. The command COLUMN makes a block with the DATA clause. So it should be:
cBlock := "Eval(...)"
BTW, if you do not use the COMMAND COLUMN then it will be ok.
Regards,
How do I make REPORT columns to access an array?
Publicado: Jue Jun 06, 2013 6:53 pm
por ChrisGillard
Hi Ignacio,
Thank you for helping.
In your second post I am understanding the the command syntax will make the block for me, ok.
I'm not understanding what should the cBlock string really look like in my situation.
I could do with you cBlock := line being more detailed.
I also worry that in my situation I am making these extra columns in a loop and they are a variable number of columns required depending on the parse of the data on the YEVET->EVENT field.
Just a little more help would be fantastic.
Thanks
Chris
How do I make REPORT columns to access an array?
Publicado: Lun Jun 10, 2013 12:11 pm
por ignacio
ChrisGillard escribió el jue, 06 junio 2013 18:53Hi Ignacio,
Thank you for helping.
In your second post I am understanding the the command syntax will make the block for me, ok.
I'm not understanding what should the cBlock string really look like in my situation.
I could do with you cBlock := line being more detailed.
I also worry that in my situation I am making these extra columns in a loop and they are a variable number of columns required depending on the parse of the data on the YEVET->EVENT field.
Just a little more help would be fantastic.
Thanks
Chris
Take a look of this code:
METHOD Report( cTitle ) CLASS TDBBrowse
LOCAL oReport, oCol
DEFAULT cTitle TO ::oDataset:cName
REPORT oReport ;
TITLE cTitle ALIGN taLEFT ;
PREVIEW MODAL ;
DATASET ::oDataset
FOR EACH oCol IN ::aCols
WITH OBJECT oReport:AddColumn()
:aTitle := { {|| oCol:cHeader } }
:aData := { {|| oCol:Value } }
:Create()
END WITH
NEXT
oReport:Run()
RETURN NIL
This is a simple code to include a Report() method to any TDBBrowser. As you can see we have use the command for the report creation, bu the columns have been created directly. The property TColumn:aData is an array of codeblocks but its complexity is hidden by the command.
In your case it will be something like this:
oColumn1:aData := { {|| aData[ nFor, 1 ] } }
oColumn2:aData := { {|| aData[ nFor, 2 ] } }
oColumn3:aData := { {|| aData[ nFor, 3 ] } }
I hope it helps.
Best regards,
How do I make REPORT columns to access an array?
Publicado: Lun Jun 10, 2013 12:33 pm
por ChrisGillard
Hi Ignacio,
Thanks for the detailed explanation of how to do this including how to use an array for each column.
I note also you are using TReport on a dbfdataset which is very useful as my understanding was it could only use TReport on USE MYDBF type of code. By re reading the help file I see you say it is initially configured that way but with the skip block of course we can be much more flexible!
Over the weekend I did get round my problem by using 'dummy' columns and the using OnPrintData, oPrintTitle & bSkip to achieve the same thing.
Same end result I think.
As always Xailer does the job when you know how.
Thanks again.
Chris
Attached files
How do I make REPORT columns to access an array?
Publicado: Lun Jun 10, 2013 12:49 pm
por ignacio
Hi Crhis,
Glad you got it!! BTW, sorry for the delay on answering.
Best regards,