//+------------------------------------------------------------------+
//| スクリプトプログラム開始関数 |
//+------------------------------------------------------------------+
void OnStart()
{
//--- 文字列を宣言して初期化する
string str="Test ZeroMemory func";
//--- ZeroMemory()を適用する前にログに行を送信する
PrintFormat("The line before applying ZeroMemory() to it: '%s'",str);
//--- 文字列をリセットし、結果をログに送信する
ZeroMemory(str);
Print("The same line after applying ZeroMemory() to it: '",str,"'");
/*
結果:
The line before applying ZeroMemory() to it: 'Test ZeroMemory func'
The same line after applying ZeroMemory() to it: ''
*/
//--- int型の変数を宣言して初期化する
int var=123;
//--- ZeroMemory()を適用する前にログに行を送信する
PrintFormat("\nThe integer variable before applying ZeroMemory() to it: %d",var);
//--- 変数をリセットし、結果をログに送信する
ZeroMemory(var);
PrintFormat("The same variable after applying ZeroMemory() to it: %d",var);
/*
結果:
The integer variable before applying ZeroMemory() to it: 123
The same variable after applying ZeroMemory() to it: 0
*/
//--- int型の配列を宣言して初期化する
int arr[]={0,1,2,3,4,5,6,7,8,9};
//--- ZeroMemory()を適用する前にログに配列を送信する
Print("\nThe integer array before applying ZeroMemory() to it:");
ArrayPrint(arr);
//--- 配列をリセットし、結果をログに送信する
ZeroMemory(arr);
Print("The same array after applying ZeroMemory() to it:");
ArrayPrint(arr);
/*
結果:
The integer array before applying ZeroMemory() to it:
0 1 2 3 4 5 6 7 8 9
The same array after applying ZeroMemory() to it:
0 0 0 0 0 0 0 0 0 0
*/
//--- 2つのフィールド(文字列フィールドと整数フィールド)の構造体を宣言する
struct STest
{
string var_string;
long var_long;
};
//--- STest構造体型の配列を宣言して初期化する
STest arr_struct[]={ {"0",0}, {"1",1}, {"2",2}, {"3",3} };
//--- ZeroMemory()を適用する前にログに配列を送信する
Print("\nThe array struct before applying ZeroMemory() to it:");
ArrayPrint(arr_struct);
//--- 構造体配列をリセットし、結果をログに送信する
ZeroMemory(arr_struct);
Print("The same array struct after applying ZeroMemory() to it:");
ArrayPrint(arr_struct);
/*
結果:
The array struct before applying ZeroMemory() to it:
[var_string] [var_long]
[0] "0" 0
[1] "1" 1
[2] "2" 2
[3] "3" 3
The same array struct after applying ZeroMemory() to it:
[var_string] [var_long]
[0] null 0
[1] null 0
[2] null 0
[3] null 0
*/
}
|