Strand 2D array problem

To add comments, please log in or register
athan
249
athan  

ok,

my problem is on very strange array action.

I got a 2D array called filecontent where on that is [50][1] in size. its set as a global variable.

The problem is that although i set for every element of the array a different value when i m trying to print it back i keep getting the same value for all the elements!


  
   while(!FileIsEnding(handle))
   {
        filecontent[i][j]=StrToDouble(FileReadString(handle));
 
        filecontent[i][j]=i*j;
         Print("readFromFile(): i="+i+" , j="+j + "  file cont="+filecontent[i][j]);

         j++;

         if (j==2) {j=0;i++;}
   }

   FileClose(handle); //close file

   for (i=0;i<=50;i++)
      Print("readfromfile2: i="+i+",1 and fc["+i+"][0]="+filecontent[i][0]+" and fc["+i+"][1]="+filecontent[i][1]);
return;
}

on the 1st print i m taking back this :

2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=22, j=0 file cont=0
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=21, j=1 file cont=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=21, j=0 file cont=0
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=20, j=1 file cont=20
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=20, j=0 file cont=0
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=19, j=1 file cont=19
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=19, j=0 file cont=0
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=18, j=1 file cont=18
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=18, j=0 file cont=0
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=17, j=1 file cont=17
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=17, j=0 file cont=0
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=16, j=1 file cont=16
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=16, j=0 file cont=0
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=15, j=1 file cont=15
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=15, j=0 file cont=0
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=14, j=1 file cont=14
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=14, j=0 file cont=0
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=13, j=1 file cont=13
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=13, j=0 file cont=0
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=12, j=1 file cont=12
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=12, j=0 file cont=0
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=11, j=1 file cont=11
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=11, j=0 file cont=0
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=10, j=1 file cont=10
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=10, j=0 file cont=0
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=9, j=1 file cont=9
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=9, j=0 file cont=0
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=8, j=1 file cont=8
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=8, j=0 file cont=0
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=7, j=1 file cont=7
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=7, j=0 file cont=0
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=6, j=1 file cont=6
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=6, j=0 file cont=0
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=5, j=1 file cont=5
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=5, j=0 file cont=0
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=4, j=1 file cont=4
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=4, j=0 file cont=0
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=3, j=1 file cont=3
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=3, j=0 file cont=0
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=2, j=1 file cont=2
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=2, j=0 file cont=0
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=1, j=1 file cont=1
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=1, j=0 file cont=0
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=0, j=1 file cont=0
2012.01.02 18:20:15 athan5 EURUSD,H1: readFromFile(): i=0, j=0 file cont=0

and on the 2nd print this:


2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=50,1 and fc[50][0]=21 and fc[50][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=49,1 and fc[49][0]= and fc[49][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=48,1 and fc[48][0]= and fc[48][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=47,1 and fc[47][0]= and fc[47][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=46,1 and fc[46][0]= and fc[46][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=45,1 and fc[45][0]= and fc[45][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=44,1 and fc[44][0]= and fc[44][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=43,1 and fc[43][0]= and fc[43][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=42,1 and fc[42][0]= and fc[42][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=41,1 and fc[41][0]= and fc[41][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=40,1 and fc[40][0]= and fc[40][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=39,1 and fc[39][0]= and fc[39][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=38,1 and fc[38][0]= and fc[38][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=37,1 and fc[37][0]= and fc[37][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=36,1 and fc[36][0]= and fc[36][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=35,1 and fc[35][0]= and fc[35][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=34,1 and fc[34][0]= and fc[34][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=33,1 and fc[33][0]= and fc[33][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=32,1 and fc[32][0]= and fc[32][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=31,1 and fc[31][0]= and fc[31][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=30,1 and fc[30][0]= and fc[30][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=29,1 and fc[29][0]= and fc[29][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=28,1 and fc[28][0]= and fc[28][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=27,1 and fc[27][0]= and fc[27][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=26,1 and fc[26][0]= and fc[26][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=25,1 and fc[25][0]= and fc[25][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=24,1 and fc[24][0]= and fc[24][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=23,1 and fc[23][0]= and fc[23][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=22,1 and fc[22][0]=0 and fc[22][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=21,1 and fc[21][0]=0 and fc[21][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=20,1 and fc[20][0]=0 and fc[20][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=19,1 and fc[19][0]=0 and fc[19][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=18,1 and fc[18][0]=0 and fc[18][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=17,1 and fc[17][0]=0 and fc[17][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=16,1 and fc[16][0]=0 and fc[16][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=15,1 and fc[15][0]=0 and fc[15][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=14,1 and fc[14][0]=0 and fc[14][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=13,1 and fc[13][0]=0 and fc[13][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=12,1 and fc[12][0]=0 and fc[12][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=11,1 and fc[11][0]=0 and fc[11][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=10,1 and fc[10][0]=0 and fc[10][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=9,1 and fc[9][0]=0 and fc[9][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=8,1 and fc[8][0]=0 and fc[8][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=7,1 and fc[7][0]=0 and fc[7][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=6,1 and fc[6][0]=0 and fc[6][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=5,1 and fc[5][0]=0 and fc[5][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=4,1 and fc[4][0]=0 and fc[4][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=3,1 and fc[3][0]=0 and fc[3][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=2,1 and fc[2][0]=0 and fc[2][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=1,1 and fc[1][0]=0 and fc[1][1]=21
2012.01.02 18:20:15 athan5 EURUSD,H1: readfromfile2: i=0,1 and fc[0][0]=0 and fc[0][1]=21

So any advices/ideas?

Simon Gniadkowski
17271
Simon Gniadkowski  
athanfx:

ok,

my problem is on very strange array action.

I got a 2D array called filecontent where on that is [50][1] in size. its set as a global variable.

First thing that springs to mind is that your array is 50 x 1 . . . but you seem to want 50 x 2 in your code.
William Roeder
22339
William Roeder  

actually he wants 51 x 2 in the code

The second thing is size can not be set by a global variable. Either the size must be a constant or you must resize it and he didn't post that code.

athan
249
athan  

thanks for your answers

that was the problem.

Athan

To add comments, please log in or register