Functions on MQL4

 
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:

Double Product_3Numbers (double x, double y, double z)
{
Result= x*y*z;
Return(result);
}

What happens if before calling the function I defined a variable that has the name Result and use that variable into the function?
Like this:

Double Result = 1;
Double BlaBlaBla = 2;
Double Hello = 3;

Product_3Numbers (Result, BlaBlaBla, Hello);

What would happen in this situation taking in account that there are 2 variables with the same name in the body of the function?
 
  1. 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

  2. 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

  3. Post code that compiles. There is nothing in MT4/MT5 called Double or Return.
  4. Your posted code won't compile as Result hasn't been declared before/at you use it in the function.
  5. 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.
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.

Reason: