?
Solved

Printing Crysatl Reports Array

Posted on 2014-04-15
2
Medium Priority
?
618 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 101

Accepted Solution

by:
mlmcc earned 2000 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
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…
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…

719 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