| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| Not all control paths return a value - advice please https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=5152 |
Page 1 of 1 |
| Author: | Nufty [ Wed Apr 26, 2017 1:18 pm ] |
| Post subject: | Not all control paths return a value - advice please |
Hi Its been a few years since I looked at coding, and I thought I would start fresh. It began well too, fixed most errors in a simple EA (not one to trade.. just learning) but I am stuck on this error Code: Select all Any advice is appreciated Thanks Nufty |
|
| Author: | mejayusa [ Wed Apr 26, 2017 2:43 pm ] |
| Post subject: | Not all control paths return a value - advice please |
The compiler is complaining because in the primary else block the code will return a value only if a specific condition is met. Compiler doesn't know how the code will behave at runtime and is trying to tell you that your method might not return a value if it goes into the second else statement. |
|
| Author: | SteveHopwood [ Wed Apr 26, 2017 5:35 pm ] |
| Post subject: | Not all control paths return a value - advice please |
Here is an example of what mejayusa is saying, in a function I coded earlier. Never mind what its' function is: Code: Select all Always include a final default return whenever you code a function that is not a void function. |
|
| Author: | Nufty [ Wed Apr 26, 2017 10:42 pm ] |
| Post subject: | Not all control paths return a value - advice please |
Thank you mejayusa and Steve for your replies Having another go now Regards Nufty |
|
| Author: | Nufty [ Wed Apr 26, 2017 11:29 pm ] |
| Post subject: | Not all control paths return a value - advice please |
It compiled I think thats my first ever Thanks again Now... to code something I actually think might work |
|
| Author: | SteveHopwood [ Thu Apr 27, 2017 8:20 am ] |
| Post subject: | Not all control paths return a value - advice please |
| All times are UTC | Page 1 of 1 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|