Hi all. Can a function return multiple values (comma separated) ?
return(1,2)
Or is it nonsense? :)) I just need to define the order price and lot, but it's not rational to write two functions for it.
Formally, it cannot. I.e., the function returns one value, but it may return a structure or a class (which is the same thing). Unfortunately, in MQL4 it is impossible, except for returning a structure that fits into 4 bytes (int). Then the information can be extracted using bitwise operations. Also you can experiment with DOUBLE and STRING.
sergeev:
function can return a value in the parameter passed to it by reference &
In this case, the function modifies the parameter. Only returns the result in return.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Thank you
Hi all. Can a function return multiple values (comma separated) ?
return(1,2)
Or is it nonsense? :)) I just need to specify lot and order price. It's not rational to write two functions for it.
The function can return a value in the parameter passed to it by reference &
the function can return a value to the parameter passed to it by reference &
Where can I read more about it? I can't find it in the documentation here on the site. Thank you very much in advance.
Where can I read more about it? I can't find it in the documentation here on the website. Thank you very much in advance.
https://docs.mql4.com/ru/basis/variables/formal
Hi all. Can a function return multiple values (comma separated) ?
return(1,2)
Or is it nonsense? :)) I just need to specify lot and order price, but it's not rational to write two functions for it.
The number is unlimited.
Hi all. Can a function return multiple values (comma separated) ?
return(1,2)
Or is it nonsense? :)) I just need to define the order price and lot, but it's not rational to write two functions for it.
Formally, it cannot. I.e., the function returns one value, but it may return a structure or a class (which is the same thing). Unfortunately, in MQL4 it is impossible, except for returning a structure that fits into 4 bytes (int). Then the information can be extracted using bitwise operations. Also you can experiment with DOUBLE and STRING.
function can return a value in the parameter passed to it by reference &
... except for the return of a structure that fits within 4 bytes (int). Further information can be extracted using bitwise operations.
You can alsochop upint in pieces with division(/) and remainder of division(%) operations.
It's easier to return a string and then parse it, you can put a lot of information there :)
You can alsochop an int into pieces using division(/) and remainder of division(%) operations.
You can also experiment with DOUBLE and STRING.