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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Working with arrays

Status
Not open for further replies.
Jan 20, 2003
41
US
I am working with CR8.5 and reporting off of a SQL 2000 DB. I created this array to store weights. I am unable to access the contents of the array from another formula.

Numbervar array wtarray;
global Numbervar counter;
counter := counter + 1;

if counter <=1000
then (redim preserve wtarray[counter];
wtarray[counter]:={MR.CurrentWeight});

I tried access the value by entering wtarray[3] in another formula and was unsuccessul. Can anyone offer guidance on how to reference the values of an array outside of the formula in which it was defined?
 
You need to delcare any variables that you are using in each formula that you are using them in.

Try using this in your formula that you are having problems with:
Code:
Numbervar array wtarray;
wtarray[3];

Also, with your first formula, another option would be to use the ubound function and eliminate the need for the counter variable.
Code:
Numbervar array wtarray;

if ubound(wtarray) <= 1000 then 
    (redim preserve wtarray[ubound(wtarray)+1];
     wtarray[ubound(wtarray)]:={MR.CurrentWeight});




~Brian
 
When I declare the variable in the second formula, does it retain the value assigned from the first formula?
 
Yes. In Crystal, you must declare the variable in every formula that you use it in. It will retain its value from formula to formula unless you set it to something else.

~Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top