//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//--- declaramos e inicializamos a string
string str="Test ZeroMemory func";
//--- imprimimos no log a string antes que ZeroMemory() seja aplicada a ela
PrintFormat("The line before applying ZeroMemory() to it: '%s'",str);
//--- zeramos a linha e registramos o resultado
ZeroMemory(str);
Print("The same line after applying ZeroMemory() to it: '",str,"'");
/*
Resultado:
The line before applying ZeroMemory() to it: 'Test ZeroMemory func'
The same line after applying ZeroMemory() to it: ''
*/
//--- declaramos e inicializamos uma variável com o tipo int
int var=123;
//--- imprimimos no log a string antes que ZeroMemory() seja aplicada a ela
PrintFormat("\nThe integer variable before applying ZeroMemory() to it: %d",var);
//--- zeramos a variável e registramos o resultado
ZeroMemory(var);
PrintFormat("The same variable after applying ZeroMemory() to it: %d",var);
/*
Resultado:
The integer variable before applying ZeroMemory() to it: 123
The same variable after applying ZeroMemory() to it: 0
*/
//--- declaramos e inicializamos um array com o tipo int
int arr[]={0,1,2,3,4,5,6,7,8,9};
//--- imprimimos no log o array antes que ZeroMemory() seja aplicada a ele
Print("\nThe integer array before applying ZeroMemory() to it:");
ArrayPrint(arr);
//--- zeramos o array e registramos o resultado
ZeroMemory(arr);
Print("The same array after applying ZeroMemory() to it:");
ArrayPrint(arr);
/*
Resultado:
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
*/
//--- declaramos uma estrutura de dois campos: string e inteiro
struct STest
{
string var_string;
long var_long;
};
//--- declaramos e inicializamos um array com o tipo STest
STest arr_struct[]={ {"0",0}, {"1",1}, {"2",2}, {"3",3} };
//--- imprimimos no log o array de estruturas antes que ZeroMemory() seja aplicada a ele
Print("\nThe array struct before applying ZeroMemory() to it:");
ArrayPrint(arr_struct);
//--- zeramos o array de estruturas e registramos o resultado
ZeroMemory(arr_struct);
Print("The same array struct after applying ZeroMemory() to it:");
ArrayPrint(arr_struct);
/*
Resultado:
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
*/
}
|