Download MetaTrader 5
To add comments, please log in or register
Millions of traders download codes from MQL5 library. Share your app with them!
Selvan
53
Selvan 2015.12.08 19:03 

dear sir,

How can i pass variable value between two functions, and whats wrong in the below code,
if i am in function  two(), how can i able to get/set value of a in function one() or get or set value of function three(), 
please make change in such a way that i can able to get the value or set the value of function one() and function three ()
from function two()
int start()

//int  OnInit()    

  {


one();
two();
three();

 return(0);

}



int one()

{

int a;
 a=10;
 return (a)   ; 
   
}


int two()
{

int b;
b=20;
return(b);
}



int three()
{
int d;

d = one(a); // why i am not able to get a value ( a value is defined in one() )
return;
}
Keith Watford
Moderator
7887
Keith Watford 2015.12.08 19:58  
int start()
  {
   int aa=one();
   int bb=two();
   int dd=three();
   Print(dd);

   return(0);
  }
  
//+------------------------------------------------------------------+
int one()
  {
   int a;
   a=10;
   return (a);
  }
//+------------------------------------------------------------------+
int two()
  {
   int b;
   b=20;
   return(b);
  }
//+------------------------------------------------------------------+
int three()
  {
   int d;
   d=one(); 
   return(d);
  }
//+------------------------------------------------------------------+

I am not quite sure what you are trying to achieve, but the above modifications may help.

You could also pass variables to a function by reference

Selvan
53
Selvan 2015.12.09 02:14  
Thankyou  so much
/
To add comments, please log in or register