Solved

Printing Crysatl Reports Array

Posted on 2014-04-15
2
557 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

776 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