I'm designing a report that calculates the faxing costs for the company.
Call cost being dependant on, time of day, destination number and duration of call. I'd decided to create formula to determine time of day and another to categorise the destination number(ie local, national, etc...). The duration of the call is taken from a field in a table.
I was going to have both of these functions return a number and these numbers where going to be passed as indexes to my 2D array. The value at this location being the rate per second for the appropriate destination and time of day.
But if I cant use my 2D array I guess i've to look at it from a different angle.
Something along the lines of getting the function that determines what category the call goes into (local, national, international, etc...) to return a rate depending on the time of day. This would bypass the need for an array but if i want to change all the rates it gets messy.
Having 2 different arrays is very different than having a 2D array. A 2D array is an array of arrays.
foz:
If your rates table can't be joined to your calls table, then you could use 3 arrays to hold your rates. One for array each for local, national, and international. There could be 24 elements for each array; each element holding the rate for that hour. You could populate these arrays in a subreport that would reside in the Report Header.
In your formula to determine the charge, you could determine the destination, so that you know which array to use to find the rate, then calculate the charge.
Brian - It may not be as convenient....but 2 separate single arrays can do the job of one 2 dimensioned array...as long as you pay attention to what you are doing.
brian:
basically there are 31 call types and 3 different call rates for each call type. the array would have been a 3*31 array. so 3 1d arrays might work.
For the moment i've bypassed the arrays, just because i need to get this done fairly soon.
Question:
If i get my calltype formula to return a string, name of the array for that call type, is there a function equivalent to the javascript eval()?
If you wanted to mimic a 2D array, you would need an additional array for each of your items in your first array. My only point was that you can't truly mimic a 2D array with just 2 arrays.
foz:
I am not familiar with the javascript function eval(). If you can give me an explanation, I can let you know what might be the equivilant in Crystal.
f0z stated that he thinks he could use 3 arrays to accomplish what he needs, not me. I think that 3 arrays would not accomplish what he is trying to do.
There are 31 different call types, and 3 different rates (depending on time of day) for each call type.
If Crystal supported 2D arrays, you'd create an array that was 31 by 3. Your first element would be the call type (local, national, etc.) and then within each of those, you would have the 3 rates. Element 1 might mean Midnight to 8am, 2 might mean 8am to 6pm, and 3 might mean 6pm to Midnight.
If you tried to use just 2 arrays, you would only have one rate structure. The rates are different for each call type. To mimic the 2D array, you would need 31 or 32 arrays. At that point, it is probably better to seek an alternate method, if possible.
I think you ought to take a look at trying to have your rate returned in your recordset and abandoning the whole array thing. Your arrays would end up being hard coded and would require a manual effort to update them whenever they changed.
If you can use a Stored Procedure, you will save yourself alot of effort down the road.
i see...sorry...I didn't read closely enough....we have nothing to argue about...[grin]
basically there are 31 call types and 3 different call rates for each call type. the array would have been a 3*31 array. so 3 1d arrays might work.
How about this approach. A string is considered an array in Crystal. I don't know what the format of the CallRate is but it can be made into a string of a standard length....
So...you don't want to hard code this because of the maintenance of the report...a stored proceedure would work perhaps....but you could also do it in a subreport in the main report header
in this subreport you would create a shared string array with each string having a very defined structure
for example
Rate1 would be the rate for say Midnight to 6AM
Rate2 would be the rate for say 6AM to 6PM
Rate3 would be the rate for say 6PM to Midnight
now in your main report when you are looking for a rate value you just loop through this array looking for the location in the first 50 chars (justified to the left & padded with blanks to 50) and then when you find it if you want Rate1 then you take ArrayInfo[x] [51 to 60]....or mid(ArrayInfo[x],51,10) if you like.
Jim Broadbent
The quality of the answer is directly proportional to the quality of the problem statement!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.