Hello, I'm learning a few programming languages, including MQL4, and I came up with a question that I didn't managed to find the answer on reference guides.
When you define a new function, lets say a simple one:
What would happen in this situation taking in account that there are 2 variables with the same name in the body of the function?
- A simple program
- What language is MQL4 and 5
- Programming guide / help files
- When you post code please use the CODE button (Alt-S)!
(For large amounts of code,
attach it.)
Please edit
your post.
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor -
Please don't add text inside quoted text or CODE blocks, put it outside.
MQL4 forum editor problem - MQL4 and MetaTrader 4 - MQL4 programming forum - Post code that compiles. There is nothing in MT4/MT5 called Double or Return.
- Your posted code won't compile as Result hasn't been declared before/at you use it in the function.
- If you move your Result above and outside the function (globally declared,) then it will set the variable and return the value. (Bad coding style.)
FernandoBorea:
Hello, I'm learning a few programming languages, including MQL4, and I came up with a question that I didn't managed to find the answer on reference guides.
Hello, I'm learning a few programming languages, including MQL4, and I came up with a question that I didn't managed to find the answer on reference guides.
When you define a new function, lets say a simple one:
What would happen in this situation taking in account that there are 2 variables with the same name in the body of the function?
MQL is case sensitive, pay attention on it.
Double isn't the same like double, Return isn't return...
If you define variables result and Result you have two different variables.
I agree with whroeder1 at all his points.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register