Download MetaTrader 5
To add comments, please log in or register
Add the thread to Favorites. Track the changes even faster!
mop0
197
mop0 2014.02.06 13:02 

Just a curiosity question more than anything, since I deleted most of the return(0)s in the old build with no ill effects.

The new 600 build debugger keeps telling me off if I accidentally copy and paste return(0); into the void OnTick section.

My solution was to delete return(0).

darksideofthemoon
57
darksideofthemoon 2014.02.06 13:18  

Functions with return type void do not or must not return a type.

Ian Venner
2583
Ian Venner 2014.02.06 14:27  

If you need a return to exit the void type function you can use return; without parenthesis.

whroeder1
13602
whroeder1 2014.02.06 14:37  
eempc:

Just a curiosity question more than anything, since I deleted most of the return(0)s in the old build with no ill effects.

The new 600 build debugger keeps telling me off if I accidentally copy and paste return(0); into the void OnTick section.

My solution was to delete return(0).

  1. The old builds was int start(){} so a return(0); was appropriate. The actual value was ignored so simply falling off the end brace was fine.
  2. The new build is void OnTick(){} so a return(anything); is wrong. Either return; or just fall off the end brace.
mop0
197
mop0 2014.02.06 15:33  

"A return operator terminates the current function execution and returns the control to the calling program. A return(expression); operator terminates the current function execution with result transmission. The operator expression must be enclosed in parentheses and should not contain an assignment operator."

The above is not exactly the most newbie-comprehensible language to read. If I understand it correctly, the point of return/return(0) is to terminate the EA for the current tick. And then, when the next tick arrives, everything inside int start(){} starts all over again until it hits another return?

So now that I am transferring my old code to the 600 build, I still need to include a return; at the very end?

Edit: nevermind, I read now that I can just let the code fall off the end brace without a final return.

/
To add comments, please log in or register