Parameters passed to the function are local. Scope is the function block. Formal parameters must have names
differing from those of external variables and local variables defined
within one function. In the block of the function to the formal parameters
some values can be assigned. Some values can be assigned to formal parameters
in the function block.
関数に渡されたパラメータはローカル変数です。有効範囲は関数ブロック内です。仮引数は外部変数や関数の中で定義されたローカル変数のそれらとは違っている名前を持つ必要があります。関数ブロック内で仮引数に何かの値を代入することができます。何かの値が関数ブロック内で仮引数に割り当てることができます。
Examples:
例:
void func(int x[], double y, bool z)
{
if(y>0.0 && !z)
Print(x[0]);
...
}
Formal parameters can be initialized by constants. In this case, the initializing value is considered as the default value. Parameters, next to the intialized one, must also be initialized.
仮引数は定数によって初期化できます。この場合、初期値は規定値と見なされます。初期化された次のパラメータも、初期化する必要があります。
Examples:
例:
void func(int x, double y = 0.0, bool z = true)
{
...
}
When calling such a function, the initialized parameters can be omitted,
the defaults being substituted instead of them.
このような関数を呼び出すときは、初期化パラメータは省略することができ、デフォルト値を使ってその代わりにできます。
Examples:
例:
func(123, 0.5);
MQL4-library functions imported within other modules cannot have parameters initialized by default values.
他のモジュールからインポートされた MQL4-ライブラリ機能は、規定値で初期化されたパラメータを持つことは出来ません。
Parameters are passed by value, i.e., modifications of the corresponding
local variable inside the called function will not be shown in the calling
function in any way. It is possible to pass arrays as parameters. However,
for an array passed as parameter, it is impossible to change values of
its elements.
渡されたパラメータの値、すなわち、呼び出した関数の中のローカル変数に対応する変更は、呼び出している関数には一切表示されません。配列をパラメータとして渡すことが出来ます。ただし、パラメータとして渡される配列の場合、その要素の値を変更することはできません。
It is also possible to pass parameters by reference. In this case, modification
of such parameters will be shown in the corresponding variables in the
called function passed by reference. Array elements cannot be passed by
reference. Parameters can be passed by reference only within one module,
such possibility being not provided for libraries. In order to inform that
a parameter is passed by reference, it is necessary to put the & modifier
after the data type.
パラメータを参照渡しすることも出来ます。この場合、これらのパラメータの修正は、参照渡し呼び出しをした関数で対応するパラメータにも反映されます。配列の要素を参照渡しすることはできません。パラメータは1つのモジュールだけの中で参照渡しすることができ、このような実現性はライブラリには提供できません。パラメータを参照渡しされることを通知するために、データ型のまえに
& 修飾子を付ける必要があります。
Examples:
例:
void func(int& x, double& y, double& z[])
{
double calculated_tp;
...
for(int i=0; i<OrdersTotal(); i++)
{
if(i==ArraySize(z)) break;
if(OrderSelect(i)==false) break;
z[i]=OrderOpenPrice();
}
x=i;
y=calculated_tp;
}
Arrays can be passed by reference, as well, all changes being shown in
the source array. Unlike simple parameters, arrays can be passed by reference
into library functions, as well.
配列は参照渡しすることができ、すべての変更を元の配列に示すこともできます。簡単なパラメータとは異なり、配列をライブラリ関数にも参照渡しすることができます。
Parameters passed by reference cannot be initialized with defaults.
参照渡しのパラメータは、デフォルト値で初期化することはできません。
Into function cannot be passed more than 64 parameters.
64個を超えるパラメータを関数に渡すことはできません。
|