Print Page | Close Window

Best Way to Print Out Array Values?

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=4700
Printed Date: 02 May 2024 at 5:32am


Topic: Best Way to Print Out Array Values?
Posted By: Luis2101
Subject: Best Way to Print Out Array Values?
Date Posted: 03 Nov 2008 at 8:55am
Hello all,

My situation is the following:
I have several global array variables that each hold 26 values. These are things like calculated dates, and different totals for several categories. I have no problem calculating all my totals and values for the report and storing them in the arrays, however, I'm not sure what the best way of printing out these totals is.

The issue is that all the values that I have in my arrays are calculated, and thus, must be printed in the footer section of my report.

My issue is that I have around 6 arrays with 26 values that need to be printed out. All of them matching to each other. In other words my Array1[1] is printed in the same row as my Array2[1] value.

Other than creating a formula to simply display each of the array values (which would result in over 100 formulas being created), what can I do to print out this report information?





Replies:
Posted By: Luis2101
Date Posted: 03 Nov 2008 at 9:24am
I'm going to post a reply to my own post here, so if anyone is having the same issue in the future, they can have this as reference.

One possible solution is to create one field for each of the arrays. This formula field will iterate through the arrays, and it will have a string variable that you will concatenate the data to. Once your loop is finished, you just leave your concatenated string as your formula result.

It should look something like this:

======
global numberVar array myArray;
redim preserve myArray[20]; // resize the array to whatever it's size is, or crystal will complain
local numberVar i = 1;
local stringVar outStr;

for i := 1 to 20 do
(
    outStr := outStr + myArray + chr(10); // chr(10) is the \n char
);
outStr
======

Obviously fancy features like formatting are kind of limited for this solution, but it'll get the job done if you need something simple.

If anyone else has any other ideas, feel free to contribute.


Posted By: rahulwalawalkar
Date Posted: 04 Nov 2008 at 1:51am
Hi
 
Did you try Join function,not sure though if it will work..........
 
Join (list, delimiter)
 
Cheers
Rahul



Print Page | Close Window