[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 166

 
MikeM:


Thank you
 
Pyro:

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 &
 
sergeev:

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.

 
Pyro:


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
 
Pyro:

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.

You can pass data between different functions of one programme through global variables.
The number is unlimited.
 
Pyro:

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.
 
Zhunko:

... except for the return of a structure that fits within 4 bytes (int). Further information can be extracted using bitwise operations.


You can alsochop an int into pieces using division (/) and remainder-of-division (%) operations
 
MikeM:
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 :)
 
MikeM:
You can alsochop an int into pieces using division(/) and remainder of division(%) operations.
This is the same but through the ass. Piecewise operations are primary. They are faster.
 
Zhunko:

You can also experiment with DOUBLE and STRING.

STRING is promising, butDOUBLE is doubtful.
Reason: