Passing Parameters to a User-Defined Function

 

When we pass parameters into a user-defined function, we change the name of the variables being passed, but the values that the variable holds are obviously retained in the function. Why do we change the name of the variables when inside the UDF? This is something that has been confusing me for a while because I can't seem to find a reason for this.  

void OnStart()
  {
   int A = 5;
   int B = 10;
   int C = MyFunction(A,B);
   Alert("C = ",C);
  }
//+--------------------------------------+
int MyFunction(int Donald, int Trump)
  {
   int d = (Donald+Donald)*(Trump+Trump);
   return(d);
  }
//+---------------------------------------+

For example, why can't we just pass them in as below:

void OnStart()
  {
   int A = 5;
   int B = 10;
   int C = MyFunction(A,B);
   Alert("C = ",C);
  }
//+--------------------------------------+
int MyFunction(A,B)
  {
   int d = (A+A)*(B+B);
   return(d);
  }
//+---------------------------------------+

Why does the variable need to be renamed and declared separately when passed to the UDF rather than just not doing this is effectively my question.

Thanks in advance.

 
You may be using the same function to get values for different variables.
void OnStart()
  {
   int A = 5;
   int B = 10;
   int C = MyFunction(A,B);
   int D = 55;
   int E = 70;
   int F = MyFunction(D,E);
   
  }

You should declare the parameter variables

int MyFunction(int A,int B)
 
Keith Watford:
You may be using the same function to get values for different variables.

You should declare the parameter variables

Okay thanks Keith.
Reason: