Issue with return value in included files build 197

 

I have an included file that just has a bunch of functions I use in it.

I just upgraded to build 197 from 194.

I have a function Digit_as_Period which will convert the numbers

1,2,3...etc to M1, M5, M15... etc.

int Digit_as_Period(int Value ) {

int toreturn = 0; //0 = current time frame

switch(Value) {

****lots of cases here****

default:

toreturn = Period();

}

return(toreturn);

}

in the main program I call it like so:

say:

period = 3;

period = Digit_as_Period(period);

so now period should be 15.

Instead when I print it it's some huge crazy random number.

If I add a Print("toreturn") right before the return statement in the function, it will print 15 and then it will work and actually return 15. If that print statement isn't there, it just goes crazy.

Just found out I can also go

int temp;

temp = toreturn;

return(temp);

and that works as well.

Anyone else have similar issues?

Any ideas? help?

Thanks,

Adam

 

I had a similar problem with at calculation routine which works under the old version. Now I have installed build 197 and I had an error on the returned a 'double' value out of the method. ( It returned a mysterious 0.01 value instead). I also am using a switch

In my case I reprogrammed the method and it is now working. I guess I have to retest my whole expert.

However, the I like the "visual mode" strategy test function in this build too much, and will not regress the metatrader version.

Onwards and upwards.

 

Instead of:

"

period = 3;

period = Digit_as_Period(period);

"

Rewrite your program so the return value is the Period:

iPeriod=3;

period=Digit_as_Period(iPeriod);