That's a "by reference" parameter.
The default, and what gets used most of the time, is "by value." You pass the *value* in the parameter. If you change the parameter in the function, it only changes its local copy inside the function.
"By reference" means it passes a "reference," or a "pointer," to the variable you pass in. That means the function code indirectly references the variable in the calling function -- which means if you change the parameter in the function, you change the value of the variable in the calling function. This can be useful if you want to return more than one value from a function.
You can also return multiple values by setting global variables. But using global variables has been shown to be harder to code and maintain, since you have to remember what "magic" changes might happen when you call a function. Recommended coding practice is to not have any changes happening "behind the curtains" like that. Instead, you should return a value in the function return, or in by-reference parameters if you need more than one. It's easier to maintain and understand.
Help with MQL4 Equation
-
icon
- Trader
- Posts: 18
- Joined: Thu Apr 12, 2012 4:49 pm
Re: Help with MQL4 Equation
Thanks a lot Gary , I saw this type of call being used when referencing arrays and based on what you explained that function would then alter the content of the entire array.
Thanks
Thanks