Download MetaTrader 5
To add comments, please log in or register
Write articles, help other developers and make money
ArjanV
18
ArjanV 2014.04.08 19:34 

Hi There!

Can anybody explain to me why this piece of code:

int Day_Of_Week_Array[];
{

switch(Day())
{
case 15: Day_Of_Week_Array[1] = {3}; break
case 16: Day_Of_Week_Array[2] = {3,4}; break;
case 17: Day_Of_Week_Array[3] = {3,4,5}; break;
case 18: Day_Of_Week_Array[4] = {3,4,5,6}; break;
case 19: Day_Of_Week_Array[5] = {3,4,5,6,0}; break;
case 20: Day_Of_Week_Array[6] = {3,4,5,6,0,1}; break;
}

}

Does not work anymore after the build 600 (and up) update? Instead I get the following error message(s) :

'{' - expression expected

for every "case" line. So something seems to have changed in the way I need to declare arrays in a case switch function, but how did it change? The exact same code worked in builds prior to 600.

Thanks for your help! If you need more info, just let me know, cause this is all new to me.

Bst rgds,Arjan

Alain Verleyen
Moderator
28558
Alain Verleyen 2014.04.08 20:58  

Hello,

Please use the SRC button when you post code. Thank you.


By the way the code you post has never compiled on any build. I suggest you to check the documentation.

qjol
3243
qjol 2014.04.08 21:40  
angevoyageur:


By the way the code you post has never compiled on any build. I suggest you to check the documentation.

i also thought it's not been compiling pre B600 but i had to check it just for the curiosity completely unexpectedly it's get compiled on pre B600

note: it's not a function (i have been confused at first, and thought it's a function)

qjol
3243
qjol 2014.04.08 22:03  
int Day_Of_Week_Array[];

switch(Day())
   {
   case 15: ArrayResize(Day_Of_Week_Array, 1);
            Day_Of_Week_Array[0] = 3;
            break;
   case 16:  
            ArrayResize(Day_Of_Week_Array, 2);
            Day_Of_Week_Array[0] = 3;
            Day_Of_Week_Array[1] = 4;
            break;
   case 17: ...
        ...
   default: ...
   } 
Alain Verleyen
Moderator
28558
Alain Verleyen 2014.04.08 22:19  
qjol:

i also thought it's not been compiling pre B600 but i had to check it just for the curiosity completely unexpectedly it's get compiled on pre B600

note: it's not a function (i have been confused at first, and thought it's a function)

The posted code has never compiled on any build.

        case 15: Day_Of_Week_Array[1] = {3}; break  

semicolon is missing

But to be honest this was not my first idea.

qjol
3243
qjol 2014.04.08 22:32  
angevoyageur:

The posted code has never compiled on any build.

semicolon is missing


angevoyageur:

But to be honest this was not my first idea.


i know (guess) you thought it's function (same as i thought)
Alain Verleyen
Moderator
28558
Alain Verleyen 2014.04.08 22:44  
qjol:


i know (guess) you thought it's function (same as i thought)


Yes.
qjol
3243
qjol 2014.04.08 22:49  
completely understandable... because of the unnecessary parentheses
ArjanV
18
ArjanV 2014.04.09 19:31  

Hi everyone,

INdeed it's just like qjol said, it did indeed work on pre B600. The missing semicolon was just because of sloppy copy and paste work on my side. Next time I'll use the SRC button as suggested. Anyway, qjol code suggestion now works fine, so thanks a lot!

/
To add comments, please log in or register