Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Evaluate Value for String Array Post Reply Post New Topic
Author Message
FrnhtGLI
Senior Member
Senior Member
Avatar

Joined: 22 May 2009
Online Status: Offline
Posts: 347
Quote FrnhtGLI Replybullet Topic: Evaluate Value for String Array
     Posted: 19 Sep 2011 at 9:09am
So I'm thinking a loop will work for this issue, but I do not have ANY experience creating loops.

Here's the situation:

I have a string field that is an array of numbers separated by a comma. For instance: "250.00, 150.00, 50.00"

How could I create a loop to calculate the sum of the numbers in the array, 450.00?

If you have any other solution besides a loop, please post. I'm not committed to the loop, but I saw it as the most effective way.

Thanks.
|< /\ '][' ( )
IP IP Logged
FrnhtGLI
Senior Member
Senior Member
Avatar

Joined: 22 May 2009
Online Status: Offline
Posts: 347
Quote FrnhtGLI Replybullet Posted: 19 Sep 2011 at 10:09am
Okay, so scratch the initial question. I have a formula to add the array. Now I need to know if there is a way to create an array out of a comma delimited string variable?

Here is the Loop to add the array:

whileprintingrecords;
Global stringVar Array x := ["250.00" , "150.00", "50.00"];
global numbervar Total := 0;

numbervar h;

FOR h := 1 to UBound(x) do
(
Total := Total + ToNumber(x[h]);
);


Total;


The problem remains that i do not know the values the array will be consisted of, so I cannot plug into the formula as above. I am creating a string variable of the numbers and need to create an array out fo the string variable and use it in the above formula.

Thanks.


Edited by FrnhtGLI - 19 Sep 2011 at 10:15am
|< /\ '][' ( )
IP IP Logged
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