Array organization?

 

Hi, i do pattern search 8 times one time for every timeframe. When i find it i make a call to one function every time. This function get 3 parametres as input like this:


void Vote(int VoterID, int VoteID, datetime VotingTime)

then i want to organize the data in an array to make some basic voting system. I try it so but the array is empty when i make call to it. I'm not getting any error but something is wrong :(


int VoteSelector[8][3];

//do some check which voterID currently votes....

VoteSelector[1][1]={VoterID, VoteID, VotingTime}


//i so on until 8

Letter when i call:


int value=VoteSelector[1][1];


it returns me 0 why is that?




Please, can someone help to organize it well?

 

int ia[8][3]; // is 8 int arrays of 3 elements each. each dimension starts with element numbered 0. eg, first dimension has 8 elements numbered [0],[1],..,[6],[7]

and since two dimensional array, each of the first dimension's 8 elements are themselves seen as int arrays...


VoteSelector[1][1]={VoterID, VoteID, VotingTime}


above invalid MQL4 syntax for assignment to array elements.

refer to MetaEditor HELP: MQL4 Reference - Basics - Variables - Initialization of variables


At runtime you can for example, load int array, ia[4] (which contains 3 elements in the second dimension):

ia[3][0] = VoterID;

ia[3][1] = VoteID;

ia[3][2] = VotingTime;


to consider using array as function parameter

refer to MetaEditor HELP: MQL4 Reference - Basics - Variables - Formal parameters


excuse me if this is obvious - not making offence, ok?


hth

 

Thank you!

I done it. I do index the big array with 2 one-dimensional arrays. It it easyer this way...





#define ARRAY_SIZE_X 8
#define ARRAY_SIZE_Y 3
//---- Vote array create
int arrayIndexX[ARRAY_SIZE_X];
int arrayIndexY[ARRAY_SIZE_Y];
int arrayZ[ARRAY_SIZE_X,ARRAY_SIZE_Y];


and then index them


   for(xx=0;xx<=ARRAY_SIZE_X;xx++){arrayIndexX[xx]=xx;}
   for(yy=0;yy<=ARRAY_SIZE_Y;yy++){arrayIndexY[yy]=yy;}
   for(xx=0;xx<ARRAY_SIZE_X;xx++){for(yy=0;yy<ARRAY_SIZE_Y;yy++){arrayZ[xx,yy]=0;}}


Then i call:
arrayZ[xx,yy];



and it works

Reason: