you want to learn about "reference": https://www.mql5.com/en/forum/117210
I did not mean that I want to enter an array into the function, but the function will have a results of 2 parameters, which I put them within an array,
so the function will get 2 parameters outside of it.
I hope you understand me better, now!!
crossy:
I did not mean that I want to enter an array into the function, but the function will have a results of 2 parameters, which I put them within an array,
so the function will get 2 parameters outside of it.
I did not mean that I want to enter an array into the function, but the function will have a results of 2 parameters, which I put them within an array,
so the function will get 2 parameters outside of it.
No, an array can hold only one type of variable and that's not the way to do it anyway... You can do something like this:
void MyFunction( string& StrInput, int& IntInput ) { //do something with StrInput, IntInput } //to use this function u have to pass it actual variables (trying to pass constants will not compile).
p.s. I recommend u visit that link that phillip mentioned. He understood u just fine.
crossy:
Thankes gordon, and if the two parameters are integers or strings, Can I?
Thankes gordon, and if the two parameters are integers or strings, Can I?
Sure. But why do it in the first place? (unless u actually want to pass an array...)
crossy:
Yes, I was wronge. I want to pass an array outside of the function. Is it possible?
Like so:
void MyFunction( int& IntArray[] ) { //do something with IntArray[] } //note: when u call the function u should pass the array name with no brackets (without '[]')
Oh brother... Did u bother reading the link phillip posted? Either u didn't read it, or didn't understand it.
Arrays can only be passed by reference in MQL4 (they cannot be passed by value; they cannot be returned using return()).
Arrays can only be passed by reference in MQL4 (they cannot be passed by value; they cannot be returned using return()).
crossy:
You were clear from your first post... U just don't understand the replies.
Am i clear now?
crossy, you cannot use return() to return anything other than one single value.
if you want to return more than one value or an array you have to return it through the argument list. You must use the call-by-reference calling convention for the arguments you want to use for that, so your function can return their values through the argument list instead of return(). If you want to return values in an array you pass the function an empty array by-reference and the function will then be able to write its values directly into this array.
if you want to return more than one value or an array you have to return it through the argument list. You must use the call-by-reference calling convention for the arguments you want to use for that, so your function can return their values through the argument list instead of return(). If you want to return values in an array you pass the function an empty array by-reference and the function will then be able to write its values directly into this array.

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
Hello freinds,
I understand that a function can return ONE veriable.
If I want to return more then 1 veriable, (f.e. a number and a string), Can I defind within the function an aray (f.e. kuku[0,0] ), which its first
place is for the number and its second place is for the string, so... I returning 2 veriables? I hope you understand the "trick"...
Thanks for your responses.