Voir comment télécharger gratuitement des robots de trading
Retrouvez-nous sur Telegram !
Rejoignez notre page de fans
Un script intéressant ?
Poster un lien vers celui-ci -
laisser les autres l'évaluer
Vous avez aimé le script ? Essayez-le dans le terminal MetaTrader 5
Vues:
4053
Note:
(31)
Publié:
2013.03.29 11:55
Mise à jour:
2016.11.22 07:32
\MQL5\Files\SomeFolder\
data.txt (0.03 KB) afficher
Besoin d'un robot ou d'un indicateur basé sur ce code ? Commandez-le sur Freelance Aller sur Freelance

The script tries to attempt to move the source file from subdirectory in the terminal local folder to target file in subdirectory in the shared folder of all the client terminals. The names of files and subdirectories are specified in script input parameters. 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));
PrintFormat("The path to the shared folder of all the client terminals: %s\\Files\\",TerminalInfoString(TERMINAL_COMMONDATA_PATH));

At first, the script will use the FileIsExist() function to define, if there is a source file by the specified path in the terminal local folder, if not, then an error message will occur. Then it will be checked, if there is the target file by the specified path. If the target file does not exist, the movement will be performed without using the FILE_REWRITE flag. Otherwise, the flag is used, or the movement will not be performed.

Code:

//--- display the window of input parameters when launching the script
#property script_show_inputs
//--- input parameters
input string InpSrcName="data.txt";
input string InpDstName="newdata.txt";
input string InpSrcDirectory="SomeFolder";
input string InpDstDirectory="OtherFolder";
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
   string local=TerminalInfoString(TERMINAL_DATA_PATH);
   string common=TerminalInfoString(TERMINAL_COMMONDATA_PATH);
//--- receive file paths
   string src_path;
   string dst_path;
   StringConcatenate(src_path,InpSrcDirectory,"//",InpSrcName);
   StringConcatenate(dst_path,InpDstDirectory,"//",InpDstName);
//--- check if the source file exists (if not - exit)
   if(FileIsExist(src_path))
      PrintFormat("%s file exists in the %s\\Files\\%s folder",InpSrcName,local,InpSrcDirectory);
   else
     {
      PrintFormat("Error, %s source file not found",InpSrcName);
      return;
     }
//--- check if the result file already exists
   if(FileIsExist(dst_path,FILE_COMMON))
     {
      PrintFormat("%s file exists in the %s\\Files\\%s folder",InpDstName,common,InpDstDirectory);
      //--- file exists, moving should be performed with FILE_REWRITE flag
      ResetLastError();
      if(FileMove(src_path,0,dst_path,FILE_COMMON|FILE_REWRITE))
         PrintFormat("%s file moved",InpSrcName);
      else
         PrintFormat("Error! Code = %d",GetLastError());
     }
   else
     {
      PrintFormat("%s file does not exist in the %s\\Files\\%s folder",InpDstName,common,InpDstDirectory);
      //--- the file does not exist, moving should be performed without FILE_REWRITE flag
      ResetLastError();
      if(FileMove(src_path,0,dst_path,FILE_COMMON))
         PrintFormat("%s file moved",InpSrcName);
      else
         PrintFormat("Error! Code = %d",GetLastError());
     }
//--- the file is moved; let's check it out
   if(FileIsExist(dst_path,FILE_COMMON) && !FileIsExist(src_path,0))
      Print("Success!");
   else
      Print("Error!");
  }

Traduit du russe par MetaQuotes Ltd.
Code original : https://www.mql5.com/ru/code/1614

The20sv0.20 The20sv0.20

The semaphore trend signal indicator

Demo_FileDelete Demo_FileDelete

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

Demo_FileFlush Demo_FileFlush

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

i-IntradayFibonacci i-IntradayFibonacci

Intraday Fibonacci levels