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!

Join on a Number Parameter? 1

Status
Not open for further replies.

DataDog

Technical User
Jun 19, 2002
190
US
CR10 CE10 SQL Database

A Join Command works great on a string. We've got a Parameter that is a number that we allow multiple values (thus an array with an 'unknown' # of elements). In a Formula, When we try to do a Join on the Parameter ( join(totext({?Join test})) ), we get the error "This array must be subscripted. Example: Array".

How do I display multiple entries of a Numerical Parameter?

DataDog
'Failure Is Not An Option'
 
Hi there. Try the following code, obviously you will need to replace the parameter with your own.
whileprintingrecords;

shared numbervar counter;
shared stringvar display;


for counter := 1 to count({?Parameter }) do
(
display := display + totext({?Parameter }[counter],0,"") + ", ";
);

display;

HTH

Steve
 
Hi,
Just a little touch-up:
To avoid having to handle the terminal ',' you could use " " as the concatenated delimiter.




[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Thanks guys! I just found another (somewhat more complex) solution that solves the trailing "," without resorting to a "space" delimiter....

Here it is plagerized from another solution. p.s. I tested this one and it does work just fine.

Just change ({?Join test}) with your Parameter .....


local stringvar myparameterlist := "";
local numbervar ndx := 0;
local numbervar maxndx := UBound({?Join test});
for ndx := 1 to maxndx do
(
if ndx = maxndx then
myparameterlist := myparameterlist +
totext(({?Join test}[ndx]))
else
myparameterlist := myparameterlist +
totext(({?Join test}[ndx])) + ", "
);
myparameterlist

DataDog
'Failure Is Not An Option'
 
Or use:

numbervar counter;
stringvar display;

for counter := 1 to count({?Parameter}) do (
display := display + totext({?Parameter}[counter],0,"") + ", ");
left(display, len(display)-2);

-LB
 
Thanks lbass, you get a star for that solution!

DataDog
'Failure Is Not An Option'
 
hi everyone,

i have been seeing alternatives of join function for joining the numbers , now my problem is im having a date array(date parameter) ,i have to display all the dates selected by the user.. how can capture all the dates selected bye the user ...

ill greatfull if any one has a solution

regards
kiran
 
Just change the formatting of the parameter:

numbervar counter;
stringvar display;

for counter := 1 to count({?Parameter}) do (
display := display + totext({?Parameter}[counter],"MM/dd/yyyy") + ", ");
left(display, len(display)-2);

-LB
 
hey lbass
thats reaaly quick , thanks a lot for that...

i have the same problem with the string array..
i want to concatenate all the string parameter values the user selects... i have used join first it worked but after some time it gives me a problem. can you give me a solution..

thanks in advance
kiran
 
You should just be able to use:

join({?parm},", ")

Or you could use a return instead of a comma:

join({?parm},chr(13))

Then you would format the formula to "can grow". What do you mean that it works but then "after some time it gives me a problem"? What happens exactly? What version of CR are you using?

-LB
 
hi lbass,

i used the join function ..
let me expalin the scenario..
i have a LOV (ApplicationLOV) , its a multi select value, when user selects n values all have to be displayed. but in my case if i use the join() funcion its returning me the last application in the list. i dont know why..

i have used these formulas...
1)
shared numbervar counter;
shared stringvar display;
for counter:= 1 to count([{?ApplicationLOV}]) do
(
display := display + totext([{?ApplicationLOV}][counter]) + ", ";
);

2) "Applications Selected : " & Replace (Join ([{?ApplicationLOV}], chr(13)), ".", "");
but im not getting it

can you please suggest a solution...
regards
kiran
display;
 
Your entire formula should look like this, removing the square brackets:

"Applications Selected : " &
Replace (Join ({?ApplicationLOV}, chr(13)),".", "")

-LB
 
hi lbass,

i have first used what you have given me . like


"Applications Selected : " &
Replace (Join ({?ApplicationLOV}, chr(13)),".", "")

but it says cannot cummarize the parameter , but when i place square brakets it accpets witout any error but when executed it displays only last application in the list selected.

regards
kiran
 
hi lbass,

i have first used what you have given me . like


"Applications Selected : " &
Replace (Join ({?ApplicationLOV}, chr(13)),".", "")

but it says cannot cummarize the parameter , but when i place square brakets it accpets witout any error but when executed it displays only last application in the list selected.
we are using crystal 11.0.0.1282 version.

regards
kiran
 
I cannot recreate your problem. Do you have the formula formatted to "can grow"? The parameter was created within Crystal, correct? Maybe you should explain your settings in the parameter setup screen.

-LB
 
hi lbass,

i have not used any formula for can grow, do we have to write a formula for "can grow".

the parameter was created in business view manager, the settings for the parameter are normal,
ex. for apllication LOV

First step was to create a command table form exisiting which select only apll_name.
Second create a field in business view for prompts
then create a dynamic LOV from the field just added.

The paramter is created based on the LOV created and the options we changed is just multiselect true..other options are not changed....

Now when i create a report i use this parameter in the selection formula > records to write the formula.

as eg..
if
{?Application Name} <> ".All" then
{AppsAccessConflictSummary_BE.Application Name}={?Application Name}
else if {?Application Name} = ".All" then
true
)

and then a formula is been created to print the values user selects as this eg.
WhilePrintingRecords;
Replace (join([{?Application Name}],","),".","")

if we remove the square brackets it gives an error stating string array required.

if i use a for loop and counter values like ..eg.
WhilePrintingRecords;
local numbervar x;
local stringvar y;

for x:=1 to count([{?Snapshot Run Date}]) do
(
y:=y+ totext([{?Snapshot Run Date}][x])+", ";
);
y;

it returns only the last value..

do you find any fault in the process or there is problem in the formulas , please provide a solutions , its very urgent.

thanks & Regards
kiran


 
Are you sure that {?Application Name} is set up as a string parameter? Join() only works with strings. I only get the error message about a string array being required when the parameter is changed to a different datatype,e.g., a number. If I put square brackets around the number parameter though I get an error message that the array must be subscripted. I still believe there should not be brackets around the parameter in either formula. I won't have access to 11.0 until tomorrow afternoon to investigate this any further. I have never used business views or the dynamic parameter options, so am not sure how that might factor in.

Maybe someone else will jump in.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top