당사 팬 페이지에 가입하십시오
- 조회수:
- 4107
- 평가:
- 게시됨:
- 2013.03.27 14:46
- 업데이트됨:
- 2016.11.22 07:32
-
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동
The script searches all text files in the terminal local folder and deletes those of them whose creation data is less than the data value on the "InpFilesDate" input parameter. The terminal local folder location can be obtained calling the TerminalInfoString() function.
PrintFormat("The path to the terminal local folder: %s\\Files\\",TerminalInfoString(TERMINAL_DATA_PATH));
Note: The script will delete all text files which were created earlier than January 1st, 2010 from the terminal local folder (the InpFilesDate parameter value is default). Thus, before launching it, make sure that you have no text files with an important information in the terminal local folder.
Code:
//--- show the window of input parameters when launching the script #property script_show_inputs //--- date for old files input datetime InpFilesDate=D'2010.01.01 00:00'; //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { string file_name; // variable for storing file names string filter="*.txt"; // filter for searching the files datetime create_date; // file creation date string files[]; // list of file names int def_size=25; // array size by default int size=0; // number of files //--- allocate memory for the array ArrayResize(files,def_size); //--- receive the search handle in the local folder's root long search_handle=FileFindFirst(filter,file_name); //--- check if FileFindFirst() executed successfully if(search_handle!=INVALID_HANDLE) { //--- searching files in the loop do { files[size]=file_name; //--- increase the array size size++; if(size==def_size) { def_size+=25; ArrayResize(files,def_size); } //--- reset the error value ResetLastError(); //--- receive the file creation date create_date=(datetime)FileGetInteger(file_name,FILE_CREATE_DATE,false); //--- check if the file is old if(create_date<InpFilesDate) { PrintFormat("%s file deleted!",file_name); //--- delete the old file FileDelete(file_name); } } while(FileFindNext(search_handle,file_name)); //--- close the search handle FileFindClose(search_handle); } else { Print("Files not found!"); return; } //--- check what files have remained PrintFormat("Results:"); for(int i=0;i<size;i++) { if(FileIsExist(files[i])) PrintFormat("%s file exists!",files[i]); else PrintFormat("%s file deleted!",files[i]); } }
MetaQuotes Ltd에서 러시아어로 번역함.
원본 코드: https://www.mql5.com/ru/code/1610

The script demonstrates the example of using the FileCopy() function

The script is a simple example of using the FileFindFirst(), FileFindNext() and FileFindClose() functions

The semaphore trend signal indicator

The script demonstrates the example of using the FileMove() function