cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Printing Table of Array Values

jsstern
Explorer
0 Likes
790

I have two arrays that I am building in my report -- one with a description and one with an associated running total for that description. As I read each record, I am looking to see if the description already exists in the array. If so, the associated running total is incremented. If not, a new array element is added for each array containing the new info:

Shared NumberVar Array PkgBal;

Shared StringVar Array PkgDesc;

NumberVar i;

BooleanVar FoundIt := NO;

For i := 1 to UBound(PkgBal) Do

(

If PkgDesc[i] = Packaging-Code THEN

(

PkgBal[i] := PkgBal[i] + Balance;

FoundIt := YES;

Exit For

);

);

If FoundIt = NO THEN

(

i := Ubound(PkgBal) + 1;

Redim Preserve PkgBal[i];

Redim Preserve PkgDesc[i];

PkgBal[i] := Balance;

PkgDesc[i] :=Packaging-Code

);

In the report footer, I want to print a table of the value of the arrays:

Desc 1 Total 1

Desc 2 Total 2

etc.

Is there a way to do it without creating a Report Footer section for each possible array element (could be 100+) and creating an associated formula for each element (e.g. Desc-1 = PkgDesc[1], Desc-2 = PkgDesc[2], etc)?

Accepted Solutions (1)

Accepted Solutions (1)

ido_millet
Active Contributor
0 Likes

Yes, convert to string using ToText() function.

The reason I would advise against doing an implicit conversion using the & operator is that implicit conversion might leave you with undesired decimals and thousand separators.

Answers (1)

Answers (1)

ido_millet
Active Contributor
0 Likes

Option 1, use newLine character(s).
Option 2: do the whole thing by simply inserting a CrossTab.

jsstern
Explorer
0 Likes

Thanks, Ido. I'll use Join(x, CHR(10)). However, that won't work for the numeric array, correct? What would be the syntax for that one, or do I have to convert the numbers to strings?