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

subscript out of range message received with Global Array CRV7

Status
Not open for further replies.

NRGman

Programmer
Aug 17, 2001
5
US
I receive the following message upon report execution with a report developed with CRv7:

"A subscript must be between 1 and the size of the array"

The formula editor accepts the syntax of the formulas involved. Both formulas have the array explicitly defined as Global where it is created and loaded. The array is also referenced as a Global array in the formula that actually generates the error message. Here are the formulas:

@CurrentTot
Code:
NumberVar CurrJanS:=0;
NumberVar CurrFebS:=0;
NumberVar CurrMarchS:=0;
NumberVar CurrAprilS:=0;
NumberVar CurrMayS:=0;
NumberVar CurrJuneS:=0;
NumberVar CurrJulyS:=0;
NumberVar CurrAugS:=0;
NumberVar CurrSeptS:=0;
NumberVar CurrOctS:=0;
NumberVar CurrNovS:=0;
NumberVar CurrDecS:=0;
NumberVar CurrMthS:=0;
Global NumberVar array ActualMonthlySales:= [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];

//January:
If IsNull({CONTACT2.UFCJAN}) then CurrJanS:=0 else 
if NumericText({CONTACT2.UFCJAN}) = True then CurrJanS:=(ToNumber({CONTACT2.UFCJAN}))
else CurrJanS:=0;
//convert remaining months per Jan...

Global NumberVar array ActualMonthlySales:= [CurrJanS, CurrFebS, CurrMarchS, CurrAprilS, CurrMayS, CurrJuneS, CurrJulyS, CurrAugS, CurrSeptS, CurrOctS, CurrNovS, CurrDecS];

CurrMthS:= Sum(ActualMonthlySales [1 to 12]);
//(CurrJanS+CurrFebS+CurrMarchS+CurrAprilS+CurrMayS+CurrJuneS+CurrJulyS+CurrAugS+CurrSeptS+CurrOctS+CurrNovS+CurrDecS);

CurrMthS;
@CurrThroughLastMonth

Code:
NumberVar CurrentThruLastMonth:= 0;
Global NumberVar array ActualMonthlySales;

If {@Month} = 1 then CurrentThruLastMonth:=0 else
CurrentThruLastMonth:= ActualMonthlySales[2];
//CurrentThruLastMonth:= Sum (ActualMonthlySales [1 to ({@Month} - 1)]);
The array contains database field values corresponding to sales information for each month. Each month is a separate field value and array element.

In trying to troubleshoot this problem, I've tried to output the individual values of the array, but they appear to be null, despite the fact that I do a null test before the array is loaded and initialize the array with zeros.

Is it my logic, syntax, or am I trying to do something that CRv7 cannot do?
 
Hmmm....You don't really need the "Global" declaration. If you are sharing data between subreports you would use "Shared" values.

If both these formulas appear in the same report then there may be a timing problem.

For example: the second formula is only valid if the first has been executed

1) to force this you add "EvaluateAfter({@CurrentTot});" to the beginning of {@CurrThroughLastMonth}

2) It may also be important when both these formulas are evaluated. If they are evaluated as you are printing records it is wise to place "WhilePrinting Records;" to the beginning of each formula.

Try this since you are directing Crystal as when to do the operation....not leaving it up the Crystal itself

Good luck...Jim


PS. Don't really understand why you are redeclaring "Global NumberVar array ActualMonthlySales"....when the result of the calc can simply be assigned to one of the array elements.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top