Solved

Printing Crysatl Reports Array

Posted on 2014-04-15
2
564 Views
Last Modified: 2014-04-15
I really just simply want to print the contents of an array.  I have done this before in different languages but never is Crystal Reports.  I did some research on the web and have come up with a few simple lines of code, but it doesn't work.

Lot_Num_Array has the values of the array (it is dynamic but will always have at least one value.  ARRAY_COUNT has the amount of values in the array.  The last variable is i, and it just simply counts for the loop and prints the current value at that spot in the array.
SHARED STRINGVAR ARRAY Lot_Num_Array;
SHARED NUMBERVAR ARRAY_COUNT;
LOCAL NUMBERVAR i :=0;

WHILE (i <= ARRAY_COUNT) DO
(
i := i + 1;
Lot_Num_Array [i]
);

Open in new window


I am currently getting an error "A Subscript must be between 1 and the size of the array." but when Lot_Num_Array[] is first called i should be 1 (which I guess points to the first value in the array, not like 99% of other languages that have it start at 0).

When I take out the array printing, just to prove that the loop works, i get no errors but the formula returns TRUE.
0
Comment
Question by:Kent Fichtner
2 Comments
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 40001790
That is true, Crystal starts all arrays at 1.

You have one other problem with the formula.

A formula only returns 1 value so your loop will only print the value of the last evaluation which in this case should be the value of the last array element.

You need to create a string concatenating the values of the list.  Since this is a list of strings, there is a simple way to do it without looping.  Use the JOIN function

WhilePrintingRecords;
SHARED STRINGVAR ARRAY Lot_Num_Array;
Join(Lot_Num_Array, ChrW(13))

Open in new window


If you want to loop it is done this way

SHARED STRINGVAR ARRAY Lot_Num_Array;
SHARED NUMBERVAR ARRAY_COUNT;
LOCAL NUMBERVAR i ;
Local StringVar strOut;

For I := 1 to ARRAY_COUNT do
    strOut := strOut & Lot_Num_Array[I] & chrW(13);

strOut

Open in new window


mlmcc
0
 
LVL 4

Author Closing Comment

by:Kent Fichtner
ID: 40002038
That worked great.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question