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!

arrays as global variables

Status
Not open for further replies.

bobmorane

Technical User
Jul 2, 2002
38
FR
Hello !
I have a big problem using arrays as global variables. Here it goes :

Formula 1 :
global numbervar array m1 := makearray({#MOYH CO 1 0},{#MOYH CO 1 1},{#MOYH CO 1 10},{#MOYH CO 1 11},{#MOYH CO 1 12},{#MOYH CO 1 13},{#MOYH CO 1 15},{#MOYH CO 1 16},{#MOYH CO 1 17},{#MOYH CO 1 18},{#MOYH CO 1 19},{#MOYH CO 1 2},{#MOYH CO 1 20},{#MOYH CO 1 21},{#MOYH CO 1 22},{#MOYH CO 1 23},{#MOYH CO 1 3},{#MOYH CO 1 4},{#MOYH CO 1 5},{#MOYH CO 1 6},{#MOYH CO 1 7},{#MOYH CO 1 8},{#MOYH CO 1 9},{#MOYH CO 1 14});
MAXIMUM(m1);

Formula 2 :
global numbervar array m1;
evaluateafter({@MOYH CO MAX 1}); //it's formula 1
local numbervar i;
local numbervar nb := 0;

for i := 1 to 31 step 1 do
(
if m1 > 100 then
(nb := nb + 1)
);
nb



I use CR 8.5 and I get this message (translated from french) : an index must be between 1 and the array length
I don't understand where & when this error occur
In formula 1 all 31 running totals are verified and are OK

in formula 1, i collect the 24 hourly averages of a day, and i take the maximum one
in formula 2, i need to count the number of averages that go over 100

Thanks by advance
 
Formula 2 is trying to do work on the array, but assuming the array is longer than it really is. When you get this error, does Formula 1 actually have any value?

Use the UBound function with Formula 2.

Naith
 
hi naith,
the idea was good, I didn't even thought about it, but unfortunately it doesn't work, i get the same error message.
in the meantime i changed global to shared, may it change results ?

That's so bad i have not much time left to finish my project, so i think i'll decalre all arrays as local, and in formula 2 declare new local arrays
I know it will take more memory, but i've already created 2000 formulas&running totals, so i think 31 more variables won't be such a burden ;-) , especially when CR reads the entire database when refreshing, and i add 1440 entries each day (the database length is set to a maximum of 38 days)
 
-Update-
naith,
it works with the use of 2 local arrays, containing exactly the same values...
but i cannot wait for a long time, so i'll take note of your solutions to use them if ever i have to "improve" (weak word :) ) my reports
Bye
bob
 
I should have suggested that you start off Formula1 with WhilePrintingRecords, as you're trying to control the evaluation time of Formula2, you should also control the evaluation time of Formula1.

Glad you found a workaround anyway.

Have a good weekend,

Naith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top