Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: subscripted arrays Post Reply Post New Topic
Page  of 2 Next >>
Author Message
cmpgeek
Newbie
Newbie
Avatar

Joined: 11 Dec 2007
Online Status: Offline
Posts: 39
Quote cmpgeek Replybullet Topic: subscripted arrays
     Posted: 12 Oct 2011 at 9:34am
I have created a parameter for the end user to enter 1 or more names that they wish to see highlighted within a report.  Using that parameter, I wrote the following conditional formatting coding:
if UpperCase ({?DrHighlight}) in {CASE.SURGEON_TEXT} then Color (255,255,125) else no color
I quickly figured out that I had to add the [] array constraints to it and adjusted it to this:
if UpperCase ({?DrHighlight}[1]) in {CASE.SURGEON_TEXT} then Color (255,255,125) else nocolor
 
I then realized that it would now only highlight the first listing in the array as it is.  I added additional IF THEN statements up to ({?DrHighlight}[10]) figuring we would not have to highlight more than that at a time (we will probably never need more than 5, but would rather be safe than sorry...)
if UpperCase ({?DrHighlight}[1]) in {CASE.SURGEON_TEXT} then Color (255,255,125) else
    if UpperCase ({?DrHighlight}[2]) in {CASE.SURGEON_TEXT} then Color (255,255,125) else
    if UpperCase ({?DrHighlight}[3]) in {CASE.SURGEON_TEXT} then Color (255,255,125) else
    if UpperCase ({?DrHighlight}[4]) in {CASE.SURGEON_TEXT} then Color (255,255,125) else
    if UpperCase ({?DrHighlight}[5]) in {CASE.SURGEON_TEXT} then Color (255,255,125) else
    if UpperCase ({?DrHighlight}[6]) in {CASE.SURGEON_TEXT} then Color (255,255,125) else
    if UpperCase ({?DrHighlight}[7]) in {CASE.SURGEON_TEXT} then Color (255,255,125) else
    if UpperCase ({?DrHighlight}[8]) in {CASE.SURGEON_TEXT} then Color (255,255,125) else
    if UpperCase ({?DrHighlight}[9]) in {CASE.SURGEON_TEXT} then Color (255,255,125) else
    if UpperCase ({?DrHighlight}[10]) in {CASE.SURGEON_TEXT} then Color (255,255,125) else
nocolor
 
 
I then discovered the "A subscript must be between 1 and the size of the array" error...
 
I understand WHY it is doing it, but am still unclear as to how to fix it.  I have read a couple things about  UBOUND() but I am not sure that is what I need and don't completely understand how it works...
 
If anyone has any ideas, I would greatly appreciate them.
Thanks,
 
 
Nomi   
CR 10    
Oracle 9i
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 12 Oct 2011 at 12:30pm
why not turn it around.
 
if the {table.field} in {?parameter} then ChangeColor else NoColor?
 
it would seem to be the simple solution....unless {table.field} is like 'John Smith'  and {?parameter} is like 'John'
 
if that is the case you could loop through the {?parameter} array, like
For ii := 1 To Ubound({?parameter}) Do
(
   if ucase({?parameter})[ii] in {table.field} then (     
      ChangeColor;
  )
);
 
HTH


Edited by lockwelle - 12 Oct 2011 at 12:31pm
IP IP Logged
cmpgeek
Newbie
Newbie
Avatar

Joined: 11 Dec 2007
Online Status: Offline
Posts: 39
Quote cmpgeek Replybullet Posted: 13 Oct 2011 at 2:24am
 the {table.field} could be "John Smith"  or  "John Smith | Jane Doe" if it is a combination case.  It could also be "John Smith, III" if that is how it is listed in the main personnel screen.
Nomi   
CR 10    
Oracle 9i
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 13 Oct 2011 at 4:36am
then probably the second method would be more effective
IP IP Logged
cmpgeek
Newbie
Newbie
Avatar

Joined: 11 Dec 2007
Online Status: Offline
Posts: 39
Quote cmpgeek Replybullet Posted: 13 Oct 2011 at 5:12am
I apologize - variables have to be my weakest area here simply because I don't have much need for them and as with anything else you learn - if you don't use it - you lose it...  *sigh*
 
For that second option, would I just need to declare the numbervar ii and place that in the report header?
Nomi   
CR 10    
Oracle 9i
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 13 Oct 2011 at 5:18am
you can declare it like:
local numbervar ii;
 
rest of example...
 
 
I would think that you would put the formula in the detail section.... probably in the object that is displaying the name.
 
HTH
IP IP Logged
cmpgeek
Newbie
Newbie
Avatar

Joined: 11 Dec 2007
Online Status: Offline
Posts: 39
Quote cmpgeek Replybullet Posted: 13 Oct 2011 at 5:33am
This is what I have:
 
local numbervar ii;
 
For ii := 1 To Ubound({?DrHighlight}) Do
(
   if ucase({?DrHighlight}[ii]) in {CASE.SURGEON_TEXT} then (     
      Color (255,255,125);
  )
);
 
When I check it for errors, it tells me that "The formula result must be a number."
What am I overlooking?
Thanks again,
Nomi   
CR 10    
Oracle 9i
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 13 Oct 2011 at 6:04am
ok, it wants a number...all the time, so how about:
 
local numbervar ii;
crNoColor;
 
For ii := 1 To Ubound({?DrHighlight}) Do
(
if ucase({?DrHighlight}[ii]) in {CASE.SURGEON_TEXT} then (
Color (255,255,125);
)
);
this way it will always return a color...formulas 'return' the last value displayed
 
HTH
IP IP Logged
cmpgeek
Newbie
Newbie
Avatar

Joined: 11 Dec 2007
Online Status: Offline
Posts: 39
Quote cmpgeek Replybullet Posted: 13 Oct 2011 at 7:00am

It will let me save it as a regular formula, but when I place the same coding into the conditional formula field it still tells me that the result must be a number... 

*looking for the emoticon where the smiley face is smacking their head against a brick wall...*
Nomi   
CR 10    
Oracle 9i
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 13 Oct 2011 at 7:27am
local numbervar ii;
local booleanvar found := false;
 
For ii := 1 To Ubound({?DrHighlight}) Do
(
if ucase({?DrHighlight}[ii]) in {CASE.SURGEON_TEXT} then (      
      found:=true;
)
);
if found then
  color(255,255,125)
else
 crNoColor
 
how about this...yeah, just a variation, but you never know with CR
 
IP IP Logged
Page  of 2 Next >>
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