無料でロボットをダウンロードする方法を見る
Facebook上で私たちを見つけてください。
私たちのファンページに参加してください
私たちのファンページに参加してください
記事を気に入りましたか?MetaTrader 5ターミナルの中でそれを試してみてください。
- ビュー:
- 815
- 評価:
- パブリッシュ済み:
- 2016.09.29 12:10
- アップデート済み:
- 2016.11.22 07:34
-
このコードに基づいたロボットまたはインジケーターが必要なら、フリーランスでご注文ください フリーランスに移動
このスクリプトは、すべての端末のローカルフォルダのサブディレクトリのソースファイルをクライアント端末の共有フォルダのサブディレクトリに移動しようとします。ファイルとサブディレクトリの名前は、スクリプトの入力パラメータで指定されています。端末ローカルフォルダはTerminalInfoString()関数の呼び出しによって取得できます。
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));
スクリプトは初めにFileIsExist()関数を使って端末のローカルフォルダ内の指定したパスにソースファイルが存在するかを定め、存在しない場合はエラーメッセージを生成します。その後、指定されたパスにターゲットファイルが存在するかが確認されます。ターゲットファイルが存在しない場合は、移動はFILE_REWRITEフラグなしで行われます。存在する場合はこのフラグが使われます。さもないと移動は行われません。
コード:
//--- スクリプトの起動時に入力パラメータのウィンドウを表示する #property script_show_inputs //--- 入力パラメータ input string InpSrcName="data.txt"; input string InpDstName="newdata.txt"; input string InpSrcDirectory="SomeFolder"; input string InpDstDirectory="OtherFolder"; //+------------------------------------------------------------------+ //| スクリプトプログラム開始関数 | //+------------------------------------------------------------------+ void OnStart() { string local=TerminalInfoString(TERMINAL_DATA_PATH); string common=TerminalInfoString(TERMINAL_COMMONDATA_PATH); //--- ファイルパスを受け取る string src_path; string dst_path; StringConcatenate(src_path,InpSrcDirectory,"//",InpSrcName); StringConcatenate(dst_path,InpDstDirectory,"//",InpDstName); //--- ソースファイルが存在するかをチェック(存在しなければ終了する) 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; } //--- ターゲットファイルが既存するかをチェックする if(FileIsExist(dst_path,FILE_COMMON)) { PrintFormat("%s file exists in the %s\\Files\\%s folder",InpDstName,common,InpDstDirectory); //--- ファイルが存在するので移動は FILE_REWRITE フラグで行うべき 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); //--- ファイルが存在しないので移動は FILE_REWRITE フラグなしで行うべき ResetLastError(); if(FileMove(src_path,0,dst_path,FILE_COMMON)) PrintFormat("%s file moved",InpSrcName); else PrintFormat("Error!Code = %d",GetLastError()); } //--- ファイルが移動されたのでみてみる if(FileIsExist(dst_path,FILE_COMMON) && !FileIsExist(src_path,0)) Print("Success!"); else Print("Error!"); }
MetaQuotes Ltdによってロシア語から翻訳されました。
元のコード: https://www.mql5.com/ru/code/1614

このスクリプトはFileFlush()関数の使用例を実証します。

このスクリプトはFileIsEnding()関数の使用例を実証します。