Solved

Printing Crysatl Reports Array

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JVM error from eclipse 1 27
Using a SUBQUERY for the set variable 10 30
Cannot locate cell 15 43
first parameter x of the decimal (x, y) 1 28
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.

751 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