Here's an interesting problem I am having in Crystal 9. Although I have found a resolution I am not convinced it is the most efficient way and I am struggling to understand why the loop would not work. I have a string that I put into an array that contains lines:
FiveSentence := split({Table.Worklog},Chr(10));
I need to pull the last 5 elements in the array. However I keep getting an error that the array must be between 1 and the size of the array. The data is:
This is Line 1
This is Line 2
<Null>
This is Line 3
This is Line 4
Here is the code I am using to troubleshoot because of the array error.
Local numberVar i := 0;
Local numberVar index := 0;
(
FiveSentence := split(Worklog,Chr(10));
for i := 1 to ubound(FiveSentence) do
index := i+1;
index & count(FiveSentence);
//FiveSentence[index];
);
I get index = 5 and count(FiveSentence)=4. So when I try to pull the FiveSentence[index] it errors out with the array error. Even if I set index to match the array count the loop only pulls the last value in the array instead of each instance. I have resolved the issue using if statements and concatenated the array contents so Array[1] & Array[2] etc...since it is only 5 sentences but again there must be something I am missing because I can't even get the loop to print an index value through each iteration. Any help would be much appreciated.
FiveSentence := split({Table.Worklog},Chr(10));
I need to pull the last 5 elements in the array. However I keep getting an error that the array must be between 1 and the size of the array. The data is:
This is Line 1
This is Line 2
<Null>
This is Line 3
This is Line 4
Here is the code I am using to troubleshoot because of the array error.
Local numberVar i := 0;
Local numberVar index := 0;
(
FiveSentence := split(Worklog,Chr(10));
for i := 1 to ubound(FiveSentence) do
index := i+1;
index & count(FiveSentence);
//FiveSentence[index];
);
I get index = 5 and count(FiveSentence)=4. So when I try to pull the FiveSentence[index] it errors out with the array error. Even if I set index to match the array count the loop only pulls the last value in the array instead of each instance. I have resolved the issue using if statements and concatenated the array contents so Array[1] & Array[2] etc...since it is only 5 sentences but again there must be something I am missing because I can't even get the loop to print an index value through each iteration. Any help would be much appreciated.