Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Finding if a value is in an array Post Reply Post New Topic
Author Message
yggdrasil
Senior Member
Senior Member
Avatar

Joined: 19 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 150
Quote yggdrasil Replybullet Topic: Finding if a value is in an array
    Posted: 13 Oct 2008 at 3:24am
I have set up an array (well actually three arrays because the list is 2500 long) of postcodes.  I now need to determine, for any address record, if that particular postcode is one of those in the array.
I created the array as
BeforeReadingRecords;
StringVar Array Postcodes1 := [
"B60 3HJ",
"B60 3HL",
............
];
" "
and that seemed to be all right
 
Then I set a formula
 
WhileReadingRecords;
Local StringVar Inpostcode;
StringVar Array postcode1;
Inpostcode :=  {ADDR_DET.POST_CODE};
If Inpostcode in postcode1 then "T" else "F"
 
which was also accepted.
 
But it always returns F even when I know the postcode is in the array.
 
What am I doing wrong?Cry
 

 
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 13 Oct 2008 at 10:33am
How are you setting up postcode1?  Which version of Crystal are you using?
 
-Dell
IP IP Logged
yggdrasil
Senior Member
Senior Member
Avatar

Joined: 19 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 150
Quote yggdrasil Replybullet Posted: 13 Oct 2008 at 11:53pm
The array is as  I said, in a formula. There is another one we use elsewhere called Holidays, which lists public holidays and is then used in a formula to count working days elapsed, I used the same principle.
I'm using Crystal 10
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 14 Oct 2008 at 7:46am
Hmm...I've not worked in Crystal 10 but I'm wondering if you're hitting some sort of undocumented limitation on the arrays.
 
Are formulas with the Holidays array working correctly?  I assume that's MUCH smaller than the postal codes.  You may need to break your arrays down into smaller chuncks.  Another technique would be to add a table containing the postal codes to your database, then add it to the report with a left outer join from the postal code in your data to this new table.  You could then test to see if the value from the new table is null to determine whether or not the code is in your list.
 
-Dell
IP IP Logged
yggdrasil
Senior Member
Senior Member
Avatar

Joined: 19 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 150
Quote yggdrasil Replybullet Posted: 24 Oct 2008 at 7:04am
Thanks, that is what I am trying to get done. I don't have rights over the database, but I know a man who doesSmile
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.