| / | Forum |
|
PipRaider
2008.03.02 12:36
What's the different between: return(1); return(0); return(-1); return; thank you |
|
New Data on the 8th Week's Top Ten We decided to analyze the top-ten EAs' trading characteristics in dynamics. |
|
MaxPayne
2008.03.02 12:56
Hi,
With "return" you indicate that you want to return to the caller of the currently active function, possibly yielding a so-called return value. The first three instances return an integer, the fourth instance doesn't return any value. Cheers, Max |
|
PipRaider
2008.03.02 13:46
Hi MaxPayne, thank you for your explanation. In delphi there is BREAK operator to jump out from the current loop, EXIT operator to exit current procedure or function, or RESULT operator if i'm using function. RETURN operator i think has same meaning with the RESULT operator in delphi. In MQL4 (C), at the end of init, deinit and start built in function there's RETURN(0). Is it mean EXIT? I think we're already at the last line of current function. Why should we put RETURN(0) at the last line? Or is it mean current function is SUCCEED or generate no error value? In some case, when GetLastError() return an error value, I found that there's always Return(-1) operator. And when to use RETURN(1) operator? Thank you. |
|
edddim
2008.03.03 19:53
You use it when you need some return of value, if you don't need any return you can use void _function() { /* ... */ } and without return; at all, or use return as break operator for the main/all function. If you need return of a double value ( 1. ) you need function defined as double _function() {}, if you need string as return, you need function defined as string _function() {}.
If you need to change parameter's values, you are defining them in initializing ex.: _function( double& double_one, double& double_two ) {}, in this case both values are returned back and changed. |