Solved

Printing Crysatl Reports Array

Posted on 2014-04-15
2
531 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
Comment Utility
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
Comment Utility
That worked great.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
This is about my first experience with programming Arduino.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now