PDA

View Full Version : ReportControl OnPrepare_RowData



HenryEgal
27-May-2009, 02:41 PM
Hello there!
I am using the report control with the peDb_Type set to eRc_db_Text.

I am going through a file and only want to select certain records in this file.
I am getting an array out of bounds error message because the onprepare_rowdata must increment a counter each time it is called and not when the actual Add_item_data is sent.
Is there a way to reset this counter so it is not incremented each time the procedure is called? Or do I have to rework this somehow maybe setting up a struct array with my selected records instead of looping through the file an picking only certain records?

I think the property with the counter is piColumn_count.

This works fine if I select all records in the file based on the index. It is only a problem when I don't select a certain record in the onprepare_rowdata
Thanks for any help!!

Ian Smith
27-May-2009, 02:59 PM
Hi Henry

This should not be a problem.

In OnPrepare_RowData you must either
Call Add_Item_Data for each defined column
Or
Set pbEOF to true to stop the loop
I suspect then you are just exiting OnPrepare_RowData when you have found a record that you do not want to add.

When peDb_Type is set to eRC_db_Text

OnOpen_DataSource is called then

OnPrepare_RowDat is called repeatedly until pbEOF is set to True then

OnClose_DataSource is called.
If you would like me have a look at your code email me the three methods or post them here.

HenryEgal
27-May-2009, 03:07 PM
Ian hello there!
Yes that is correct. If I find a record I do not want to select I am exiting the procedure. I didn't set PbEOF to true because I did not want to end the loop.
I have attached a file with better formatting.

Here is what I have:

Procedure OnOpen_DataSource
Set pbEOF to False
Date dBegin dEnding

Set piCh_No to 0

Send Delete_Data of oQueryArray
Set piQueryArray to 0

Get Value of oBeginDate to dBegin
Get value of oEndDate to dEnding

If ((dBegin <> "") and (dEnding <> "")) Begin
Clear CMWORORD
Move dBegin to CMWORORD.WORK_DATE
Find GE CMWORORD by Index.3


End

Else Begin

Clear CMWEATHE
Find GE CMWEATHE by Index.1


End




End_Procedure



Procedure OnPrepare_RowData
Integer iCounter iGoOn
Integer iChild_ID
Number nTotalIncome nTemp
String sTemp
Date dTemp
Date dbegin dEnding
Move 0 to iGoOn

Get Value of oBeginDate to dBegin
Get value of oEndDate to dEnding

If ((dBegin <> "") and (dEnding <> "")) Begin
If ((CMWORORD.WORK_DATE >= dBegin) and (CMWORORD.WORK_DATE <= dEnding) and (Found = 1)) Begin
Move 1 to iGoOn

Clear CMWEATHE
Move CMWORORD.LAST_WEATHER to CMWEATHE.LAST_WEATHER
Find EQ CMWEATHE by Index.1
End
Else Begin
Set pbEOF to True
End


End

Else Begin
If (Found = 1) Begin
Move 1 to iGoOn
End
Else Begin
Set pbEOF to True
End

///no need to do anything...record already found
End

Get piCh_No to iChild_ID
Get piQueryArray to iCounter

If (iGoOn = 1) Begin

// Move 1 to iGoOn
Get Value of oCmweathe_Occupants to nTemp
If (nTemp = 0) Begin
Move 1 to iGoOn
End
Else Begin
If (nTemp <> Cmweathe.Occupants) Begin
Move 0 to iGoOn
End

End

If (iGoOn = 1) Begin
Get Value of oCmweathe_Zip to sTemp
If (sTemp <> "") Begin
Move (Trim(sTemp)) to sTemp
If (sTemp <> CMWEATHE.ZIP) Move 0 to iGoOn

End


End


If (iGoOn = 1) Begin

Set array_value of oQueryArray iCounter to CMWEATHE.RECNUM
Increment iCounter
Set piQueryArray to iCounter

Move 0 to nTotalIncome

Clear CMWEAINC
Move CMWEATHE.LAST_WEATHER to CMWEAINC.LAST_WEATHER
Find ge CMWEAINC by Index.1
While ((Found = 1) and (CMWEATHE.LAST_WEATHER = CMWEAINC.LAST_WEATHER))
Move (CMWEAINC.AMOUNT + nTotalIncome) to nTotalIncome
Find gt CMWEAINC by Index.1

Loop


Send Add_Item_Data (Trim(CMWEATHE.CASE_NUMBER))
Send Add_Item_Data (Trim(CMWEATHE.LAST_NAME))
Send Add_Item_Data (Trim(CMWEATHE.FIRST_NAME))
Send Add_Item_Data (Trim(CMWEATHE.SSN))
Send Add_Item_Data nTotalIncome
Send Add_Item_Data (Trim(CMWEATHE.ADDRESS1))
Send Add_Item_Data (Trim(CMWEATHE.CITY))
Send Add_Item_Data (Trim(CMWEATHE.ZIP))

End



End



If ((dBegin <> "") and (dEnding <> "")) Begin

Find GT CMWORORD by Index.3

End

Else Begin
Find GT CMWEATHE by Index.1
///no need to do anything...record already found
End


End_Procedure

HenryEgal
27-May-2009, 03:13 PM
Ian! Sorry about the indentation and formatting! It was lost when I pasted in.
I'll send to you in an email as well.
Thanks so much!
Henry

chuckatkinson
27-May-2009, 04:17 PM
Ian! Sorry about the indentation and formatting! It was lost when I pasted in.
I'll send to you in an email as well.
Thanks so much!
Henry

Henry take a look at the "#" icon on the forum Reply to Thread panel. It wraps markup around your code so it doesn't lose the formatting.

Ian Smith
28-May-2009, 12:34 PM
Hi Henry

Try the attached. Basically the changes are


Set pbEOF in OnOpen_DataSource if the initial find fails
Put a while loop in OnPrepare_RowData and keep track of EOF and if a valid record has been found.

Obviously I have not compiled the code.

HenryEgal
29-May-2009, 07:53 AM
Ian, thanks so much for the input!
I'm going to try this out.
Thanks!
Henry

HenryEgal
29-May-2009, 07:54 AM
ahh yes thanks Chuck!