Print Page | Close Window

Array

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=12567
Printed Date: 01 May 2024 at 3:05pm


Topic: Array
Posted By: RTSFO
Subject: Array
Date Posted: 09 Mar 2011 at 7:06pm
I have a freeform parameter in my report where user can enter any combination of values from 1 to 5. it could be any combination like 1 2 4 or 2 5 3 or 2 5 (with spaces between them)etc.
 
I am trying to use this formula in my select statement:
//and if {?parameter} <> " " then
//{table.column_name} in split({?parameter})else true.
When I try to save it. I get the below error:

"this array must be subscripted. For example: array

Can some one help?
Thank you,
RTSFO



Replies:
Posted By: Keikoku
Date Posted: 10 Mar 2011 at 2:56am
Does the parameter accept multiple values? Or a single string of zero or more numbers?

If it accepts multiple, then it's treated as an array. I've found that if you try to reference an array, you MUST specify an index (as opposed to passing that array to other functions like split).

But if it's not an array, where does crystal tell you the problem is?


Posted By: lockwelle
Date Posted: 10 Mar 2011 at 4:13am

how about trying:

stringvar array x := split({?parameter});
if {?parameter} <> " " then
  {table.column} in [x]
else
  true
 
I know it seems redundant, but if you're pulling your hair out, it is worth a try.
 
HTH


Posted By: RTSFO
Date Posted: 10 Mar 2011 at 4:42am
the parameter accepts multiple values of single digit numbers. I am getting the error when I try to save my selection forluma.
Thanks!
 


Posted By: Keikoku
Date Posted: 10 Mar 2011 at 6:32am
What is the error? where is the error? Was it with lockwelle's suggestion?


Posted By: RTSFO
Date Posted: 10 Mar 2011 at 6:43am
I get the error:
"this array must be subscripted. For example: array " the way I had it or with lockwelle's suggestion. 


Posted By: lockwelle
Date Posted: 10 Mar 2011 at 7:21am
last thought, since I have never used split the way this is using it.
So....
 
have you tried split({?parameter}, " ").
 
I don't know what split does when you don't tell it the characters to split on.
 
 
 


Posted By: Keikoku
Date Posted: 10 Mar 2011 at 9:21am
Originally posted by RTSFO

I get the error:
"this array must be subscripted. For example: array " the way I had it or with lockwelle's suggestion. 


Does it highlight where the error occurred?


Posted By: RTSFO
Date Posted: 10 Mar 2011 at 9:35am
and if {?parameter} <> " " then
{table.column_name} in split({?parameter})else true.
Yes it highlights the string in italics (the parameter)


Posted By: Keikoku
Date Posted: 11 Mar 2011 at 3:00am
I am still not clear what the parameter is, but I will assume it is something like [1, 2, 3].

This is the logic you want:

If the input has numbers
   return whether the field is in the array or not


Which would translate to


if count({?parameter}) > 0 then // contains at least one value
   {table.field} in {?parameter}





Originally posted by lockwelle

I don't know what split does when you don't tell it the characters to split on.


By default, the delimiter for the split function is a single space.




Print Page | Close Window