Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array Processing Question

Status
Not open for further replies.

cakoliver

Technical User
Mar 9, 2001
28
US
Is it possible to conditionally load an array from multiple detail records, then reference that array at the end of the group?
Example:
Reading a Cost Code Master File if a record meets certain qualifications, x is incremented and value y is loaded into Array,x. Another record is processed and conditions are met, value y from current record is loaded into Array,x+1(x was incremented)
At the end of the group print the values of the Array sorted in a specific order based on element value.
 
See Redim in the online help for dynamically changing the dimensions of an array. There are slight variations for Basic and Crystal syntax. Malcolm Wynden
I'm for sale at malcolm@wynden.net
 
Malcolm,
(or anyone who would like to help)
I've been trying to conditionally load an array and increment the index X(CR8). The only way I can get the formula to pass error checking is with the parens as follows:

whileprintingrecords ;
Global NumberVar array AdjArray;
Global numbervar X;
if {@Adjustment} <> 0 then
(redim AdjArray [X];
AdjArray [X]:={@Adjustment};
X :=X+1;)
else
(X)

If I use the parens the operations don't seem to happen, I test for X and it always has the initial value of 1.
If I leave out the parens it seems to have problems resolving the two operations inside the if structure, also it seems to want the else regardless, I really don't care about the else condition.

Thanks,
JW Oliver

 
I'm not at a PC that has CR on it, but I recall that the Redim function has some examples that use the loop/do while functions. You need to use a loop - otherwise, your if-then-else formula gets evaluated only once per record, which in this case would not do anything significant.
Gotta go, but dig in the help under redim function for loop or the do-while examples, or look directly for loop examples. Malcolm Wynden
Authorized Crystal Engineer
malcolm@wynden.net
 
Malcolm,
I only want to evaluate once per record.
If a particular record has an adjustment then
1)save the adjustment value into array element x.
2)increment x by 1 to the next highest number.
else
Dont do the above
ie. no value is put into any array element and x stays at whatever value it previously was.
Subsequent records are read and processed the same. at the end of the group I want to print a list of all the adjustments previously encountered, ie listing out the contents of all of the array elements populated by the logic in question.

Thanks,
Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top