Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine array size - Crystal 7.0 1

Status
Not open for further replies.

mesree

Programmer
Oct 4, 2002
10
IN
I have a parameter that can accept multiple values. These values are being obtained from a database table and the user can choose any 'N' number of these values.

I would like to get all the values in StringVar as a comma separated list. I am using CR 7.0 in which there is no "join" function or any looping control structure like while or for.

Can somebody pls help??
 
Dear Mesree:

This will work in version 7.0

//where {?tester} is your multivalue parameter or array

numbervar counter;
stringvar holder;
counter := count({?tester}); //gives you the # of elements
//The above formula line retrieves the number of elements in the array.
while counter > 0 do
(holder := holder + {?tester}[counter] + ',';
counter := counter - 1);
holder [1 to (length(holder)-1)] //remove the trailing ','

Hope this helps you,

ro Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
Dear Mesree,

I forgot to mention that a string has a limit of 254 characters so if the string is greater the formula will fail.

ro Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
Dear Rosemaryl,

Thanks for the reply. But there is definitely some major confusion here. The WHILE LOOP is not supported in crystal support. I have tried it personally. But Seagate's knowledgebase has this article


This article agrees that your formula works. But in fact it doesn't. Can somebody clarify this please?

Thanks Again.
 
Dear Mesree,

Okay, I tracked down a version of 7.0 and you are right doesn't work.

This formula, however, will work. I tested it. It's not elegant or short but it does the job.

First determine what the maximum number of elements the array can have.

Then use this formula:

WhilePrintingRecords;
numbervar counter;
stringvar array holder := {?tester}; //get your array

counter := count({?tester}); // replace with your parameter field gives you the # of elements


holder[1]+


if counter > 1 then ', ' + holder [2] +
if counter > 2 then ', ' + holder [3] +
if counter > 3 then ', ' + holder [4] +
if counter > 4 then ', ' + holder [5] +
if counter > 5 then ', ' + holder [6] +
if counter > 6 then ', ' + holder [7] +
if counter > 7 then ', ' + holder [8] +
if counter > 8 then ', ' + holder [9] ;

//place the number of if counters above necessary to meet
//the number of elements you allow in the multi-value parameter

Hope this helps,

ro



Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top