거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Twitter에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
조회수:
4561
평가:
(29)
게시됨:
2013.04.10 13:09
업데이트됨:
2016.11.22 07:32
MQL5 프리랜스 이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

The script sorts one by one all CSV files in the general folder of all client terminals to obtain their sizes. After getting the size, its value is compared to the "InpThresholdSize" threshold value and according to the result the file is placed either in the "InpBigFolderName", or the "InpSmallFolderName" named folder. Thus large and small dimension files are sorted.

Besides using the FileSize() function, there are also the FileFindFirst(), the FileFindNext() and the FileFindClose() functions used in the script to sort the files and the FileMove() function to move them.

Code:

//--- show the window of input parameters when launching the script
#property script_show_inputs
//--- input parameters
input ulong  InpThresholdSize=20;        // file threshold size in kilobytes
input string InpBigFolderName="big";     // folder for large files
input string InpSmallFolderName="small"; // folder for small files
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
   string   file_name;      // variable for storing file names
   string   filter="*.csv"; // filter for searching the files
   ulong    file_size=0;    // file size in bytes
   int      size=0;         // number of files
//--- print the path to the file we are going to work with
   PrintFormat("Working in %s\\Files\\ folder",TerminalInfoString(TERMINAL_COMMONDATA_PATH));
//--- receive the search handle in common folder's root of all terminals
   long search_handle=FileFindFirst(filter,file_name,FILE_COMMON);
//--- check if FileFindFirst() has been executed successfully
   if(search_handle!=INVALID_HANDLE)
     {
      //--- move files in the loop according to their size
      do
        {
         //--- open the file
         ResetLastError();
         int file_handle=FileOpen(file_name,FILE_READ|FILE_CSV|FILE_COMMON);
         if(file_handle!=INVALID_HANDLE)
           {
            //--- receive the file size
            file_size=FileSize(file_handle);
            //--- close the file
            FileClose(file_handle);
           }
         else
           {
            PrintFormat("Failed to open %s file, Error code = %d",file_name,GetLastError());
            continue;
           }
         //--- print the file size
         PrintFormat("Size of %s file is equal to %d bytes",file_name,file_size);
         //--- define the path for moving the file
         string path;
         if(file_size>InpThresholdSize*1024)
            path=InpBigFolderName+"//"+file_name;
         else
            path=InpSmallFolderName+"//"+file_name;
         //--- move the file
         ResetLastError();
         if(FileMove(file_name,FILE_COMMON,path,FILE_REWRITE|FILE_COMMON))
            PrintFormat("%s file is moved",file_name);
         else
            PrintFormat("Error, code = %d",GetLastError());
        }
      while(FileFindNext(search_handle,file_name));
      //--- close the search handle
      FileFindClose(search_handle);
     }
   else
      Print("Files not found!");
  }

MetaQuotes Ltd에서 러시아어로 번역함.
원본 코드: https://www.mql5.com/ru/code/1633

Demo_FileReadDouble Demo_FileReadDouble

The indicator demonstrates the example of using the FileReadDouble() function

Demo_FileWriteDouble Demo_FileWriteDouble

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

Demo_FileTell Demo_FileTell

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

Demo_FileWriteInteger Demo_FileWriteInteger

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