Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Array? Post Reply Post New Topic
Page  of 2 Next >>
Author Message
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet Topic: Array?
    Posted: 11 Apr 2011 at 6:19am
Hi,
 
Is there a way to create an array on a report footer?
I have a detail section which displays a rank and a code
I want to keep track of codes which have a rank of 1
so in the footer if a client has more than 1 rank of 1 then it displays 1, 2, or 3 etc
 
example
 
client1 has 1 rank of 1 with code 200
 
footer displays
client1  200
 
client2 has 1 rank of 1 with code 200 and 1 with 250
footer displays
client2  200, 250
 
 
 
Thanks
Joe
 
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 11 Apr 2011 at 6:34am
You can create a string representation of an array using several formulas.

You will need:

-one formula in the report header to initialize an empty string.
-one formula in the group header that will append the group name to it (assuming you group on "client1" etc)
-one formula in the detail section that will append the code to the string
-one formula in the group footer section to insert new-line characters (use the chr() function for this)
-one formula in the report footer that will print the string.

All formulas should use the "whileprintingrecords" keyword. They will all use the same global variable.

An example initialization formula would be


whileprintingrecords;
global stringvar output := "";


and a group header formula would be


whileprintingrecords;
global stringvar output := output & " " & {group_name}


In the end you should get something like


Client1   200
Client2   300,400,
Client3   250,450,


Dealing with the comma at the end may be difficult.

Edited by Keikoku - 11 Apr 2011 at 6:39am
IP IP Logged
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet Posted: 11 Apr 2011 at 8:59am
Ok,
 
So I got this kind of working
 
 GH: @reset -
whileprintingrecords;stringvar x := "";
 
Display @accum -
 if {Axis1Link.RANK}=1 then
whileprintingrecords;stringvar x := x + {Axis1.Code} + ", ";
 
GF: @display -
 whileprintingrecords;stringvar x;stringvar array y := split(x,", ");numbervar j := ubound(y)-1;left(x,instr(x,y[j])-1)+ (if j > 1 then "and "+ y[j]else y[j])
 
But my detail doesn't seem to want to do my If statement .
 
I only want them added if {Axis1Link.RANK}=1
 
Thanks

 
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 11 Apr 2011 at 9:43am
whileprintingrecords; //set evaluation time
stringvar x; //declare variable
if {Axis1Link.RANK}=1 then
   x := x & {Axis1.Code} & ", ";

Unless you are using basic (which I've never used), & is the crystal syntax for concatenation.

Edited by Keikoku - 11 Apr 2011 at 9:43am
IP IP Logged
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet Posted: 11 Apr 2011 at 10:03am
Thanks for getting back any chance you can explain further?
 
I found the code I used online, your way looks simpler..
Thanks
Joe
 
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 11 Apr 2011 at 10:19am
Not sure what more there is to explain.
Which part are you having trouble with?

Your display formula seems quite complicated.

It doesn't seem like an array is necessary in this case if you only want to show information.

Array is only necessary if you need to store multiple records and retrieve them at the end.

You should able to construct your string "as you go" and just print it out at the end.
IP IP Logged
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet Posted: 11 Apr 2011 at 10:26am
thanks for getting back , sorry I cant get this!!
Ok so this is what I have
in my detail  I show axis1link.rank and axis1.code
But I will be surpressing that
and in the footer I only want to display
axis1.codes that axislink.rank = 1 , but display in array fashion like
502.1, 503.1
 
Thanks
 Joe
 
 
in the group footer I wan
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 11 Apr 2011 at 5:12pm
You should construct your string in that fashion then.

x := x & " " & {code} & "." & {rank} & ", "

Then if code = 501 and rank = 1, you will have something like

501.1, 502.1, ..., 509.1,

If the last comma is aesthetically unpleasing, then in your print formula you should write

x[1 to length(x) - 2)]

This basically says to print everything except the last two characters, which from above we can see is the comma followed by a space.

Edited by Keikoku - 11 Apr 2011 at 5:13pm
IP IP Logged
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet Posted: 12 Apr 2011 at 2:57am
Thanks Keikoku,
 
This works great in the details :
whileprintingrecords; //set evaluation time
stringvar x; //declare variable
if {Axis1Link.RANK}=1 then
   x := x & {Axis1.Code} & ", ";
 
But can I display the final tally in the GF?
it seems to rest if I put it in the footer..
 
Thanks
 
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 12 Apr 2011 at 3:11am
it seems to reset if I put it in the footer..


Do you want to display it in the *report footer* or the group footer?

I think the display should be fine in the group footer.

Ok,

So I got this kind of working

GH: @reset -
whileprintingrecords;stringvar x := "";


This is why it's resetting.

Edited by Keikoku - 12 Apr 2011 at 3:11am
IP IP Logged
Page  of 2 Next >>
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.016 seconds.