Ok...I will warn you that this applies to CR 8.0 and above
to initialize an array use something like these following formulas:
@Initialize(A) (suppressed placed in the report header)
WhilePrintingRecords;
//add about 50% more array elements than what you expect to
//get in reality...ie If you expect 50 invoices plan for 75
//the ... is just to indicate more array elements of same
NumberVar array invoice := [0,0,0,0,0,0,...,0];
//same considerations for payments
NumberVar Array payment := [0,0,0,0,0,0,...,0];
NumberVar iCount := 0; // place holder for invoices
NumberVar pCount := 0; // place holder for Payments
@Initialize(B) (suppressed placed in a group header)
WhilePrintingRecords;
if not inRepeatedGroupHeader then
(
NumberVar array invoice := [0,0,0,0,0,0,...,0];
NumberVar Array payment := [0,0,0,0,0,0,...,0];
NumberVar iCount := 0;
NumberVar pCount := 0;
);
the difference between @initialize (A) and (B) is that (B) will be reset in the Group but you don't want that reset to occur unless it is a new group...it depends on what you want.
I am not sure how you want to use this but let us say that we want to store the sum of the payments for each invoice for later printout. Then Array element Invoice[1] will have all its payments summed in Payment[1]...etc
this can be done in a formula like this
Summing Payments would be done here
@addinvoice&SumPayments (Suppressed in detail or other
section you want)
WhilePrintingRecords;
NumberVar array invoice ;
NumberVar array payment;
NumberVar iCount ;
NumberVar pCount ;
if {Table.invoice} in invoice then
(
for pCount := 1 to ubound(invoice) do
(
if invoice[pCount] = {Table.Invoice} then
payment[pCount] := payment[pCount] + Table.payment};
exit for;
);
)
else
(
iCount := iCount + 1;
invoice[iCount] := {Table.invoiceNum};
payment[iCount] := payment[iCount] + Table.payment};
);
Display of invoices and payments would depend on the look that you want
If there are a lot of invoices/payments then a formula for each is probably justified...I usuall convert numbers to text for simplicity of reporting
if total characters is less than 254 use one formula if more then determine how many you can fit into one formula then add another formula or more in following sections which are enabled with "suppress Blank section"
@DisplayInvoices (enable the "can Grow" property)
WhilePrintingRecords;
NumberVar array invoice ;
NumberVar iCount ;
numberVar m;
StringVar result;
for m := 1 to iCount do
(
result := result + invoice[m] + chr(13) + chr(10);
);
result;
Note: m iCount also equals the number of Payment totals to I think.
Anyway, this may not really solve your problem but it does show how you can use arrays in formulas
Hope this helps you Jim Broadbent