using Crystal XI
I have two arrays – one captures a list of timepoints the other captures the times associated with them.
I need to associate the two so that the output looks like
timepoint[1] - time [1] - timepoint[2] - timepoint[2]; timepoint[3] - time[3] - timepoint[4] - timepoint[4];
so i wronte the following code – the arrays are intitialized in the header then loaded with data in the details section and then displayed in the group footer (three formula trick). I can display the data in the two arrays seperatly ok
(as timepoint[1], timepoint[2], etc)
the issue only arrises when trying to combine the two. the code below only prints the last two records in the array for the gorup instead of all of the records.
so if there are 5 timepoints and 5 times the code below displays
timepoint[4]-time[4] – timepoint[5]-time[5]
I will have to eventually perform a calculation between the two associated date times but for now just trying to get the association and display working.
Shared stringVar array Timepoints;
Shared DateTimeVar array Times;
local stringVar combineStr;
local numbervar i;
For i:=1 to UBound(Times)-2 do
(combineStr := Timepoints[i] + ','+ totext(Times[i]) + '-' +
Timepoints[i+1] + totext(Times[i+1]) + ',');
combineStr;
thanks for looking at this
You’re overwriting the previous value of the combineStr variable with each iteration. You need to do this:
A few other things: 1. You’ll want to concatenate a newline character, chr(10), instead of a comma between iterations to display like your example in the question. 2. You need to add “step 2” to your for-loop otherwise you’ll be printing out timepoints twice.