Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Array Post Reply Post New Topic
Author Message
RTSFO
Newbie
Newbie
Avatar

Joined: 10 Sep 2009
Online Status: Offline
Posts: 36
Quote RTSFO Replybullet Topic: Array
    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
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet 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?
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet 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
IP IP Logged
RTSFO
Newbie
Newbie
Avatar

Joined: 10 Sep 2009
Online Status: Offline
Posts: 36
Quote RTSFO Replybullet 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!
 
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 10 Mar 2011 at 6:32am
What is the error? where is the error? Was it with lockwelle's suggestion?
IP IP Logged
RTSFO
Newbie
Newbie
Avatar

Joined: 10 Sep 2009
Online Status: Offline
Posts: 36
Quote RTSFO Replybullet 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. 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet 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.
 
 
 
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet 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?

Edited by Keikoku - 10 Mar 2011 at 9:21am
IP IP Logged
RTSFO
Newbie
Newbie
Avatar

Joined: 10 Sep 2009
Online Status: Offline
Posts: 36
Quote RTSFO Replybullet 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)
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet 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.

IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.