Ughh! Print parameter field in report title using a formula

This one is a real zinger.  I'm using Crystal 8.5.  I have created a parameter field named PL which is setup as such:

string value type
allow multiple values
discrete and range values

Now, the user will typically enter values such as:

01   (discrete)
02   (discrete)
03   10  (range)

The report accepts these multiple discrete and range values and shows the results with no issues.  

I want to show all of the parameter values in a title.  I know how to create a formula and place it on the report.
But the question is how do I construct the formula given how I have setup this particular parameter field?

After much research, here is what I have tried so far and none of my attempts pass the formula editor check for various reasons:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-- Crystal Syntax

StringVar strResult := '';
NumberVar n;

for n := 1 to ubound({?PL})
do
(
   strResult := strResult + {?PL}[n];
);              ^---------------  A string is required here.

strResult


-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-- Crystal Syntax

StringVar strResult := '';
NumberVar n;

for n := 1 to ubound({?PL})
do
(
   strResult := strResult + ToText( {?PL}[n] );
);                                 ^-----------------  A number, currency amount, boolean, date, time, date-time, or string is required here.

strResult


-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-- Crystal Syntax

Join( {?PL},"," )
     ^---------------  A string array is required here.


-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-- Crystal Syntax

Join(ToText( {?PL} ),"," )
            ^-----------------  A number, currency amount, boolean, date, time, date-time, or string is required here.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-- Basic Syntax

dim i as number
dim s as string
for i = 1 to UBound({?PL})
  s = s & Chr(13) & chr(10) &  {?PL}(i)
                              ^-----------------  A number, currency amount, boolean, date, time, date-time, or string is required here.
next
formula = s



-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-- Crystal Syntax

//Declare a variable to hold the number of items in the Multiple value parameter
Global NumberVar Counter := Count({?PL});


//Declare a variable to use in the For Loop
Global NumberVar i :=1;


//Declare a string variable to hold the resulting string
Global StringVar Display;


//Loop through all of the items in the parameter.  
//Extract each and add to a string
For i := 1 to  Counter Do
    (
//Add the first parameter value to the Display variable
    If i = 1 then
        ({?PL}[i];
        Display := Display + {?PL}[i])
                   ^---------------  A string is required here.

//Add a comma to the Display variable before adding subsequent parameter values
    Else If i < Counter then
        ({?PL}[i];
        Display := Display + ", ";
        Display := Display + {?PL}[i])
//Add the word 'and' to the Display variable before the last value rather than a comma
    Else
        ({?PL}[i];
        Display := Display + " and ";
        Display := Display + {?PL}[i])
    );


//Display the variable that holds the result
Display
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


Thanks in advance,
Preece
LVL 12
PreeceAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bdreed35Commented:
Give this a try:

StringVar strResult := '';
NumberVar n;

for n := 1 to ubound({?PL})
do
(
    strResult := strResult + ", " + minimum({?PL}[n]);
    if minimum({?test}[n]) <> Maximum({?PL}[n])
    then strResult := strResult + " thru " & maximum({?PL}[n]);
);

mid(strResult,3)

I formatted it a bit different to try and make the values appear like you might want to read them
PreeceAuthor Commented:
Awesome!  And thanks for the quick response.  Would you please modify your code so that the result may read something like:

1, 2, 3, 4, (5-10), (11-15), (16-20), 21, 22

Thanks,
Preece
bdreed35Commented:
StringVar strResult := '';
NumberVar n;

for n := 1 to ubound({?PL})
do
(
    if minimum({?PL}[n]) <> Maximum({?PL}[n])
    then strResult := strResult + ", (" + minimum({?PL}[n]) & "-" & maximum({?PL}[n]) + ")"
    else strResult := strResult + ", " + minimum({?PL}[n]);
);

mid(strResult,3)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PreeceAuthor Commented:
After 3 hours of pulling my hair out, I'm really happy to have this resolved.  Thanks for your excellent solution.

Preece
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.