bool FileMove( const stringsrc_file_name, // File name for the move operation intcommon_flag, // Location const stringdst_file_name, // Name of the destination file intmode_flags// Access mode );
//— display the window of input parameters when launching the script #propertyscript_show_inputs //— input parameters inputstringInpSrcName=“data.txt”; inputstringInpDstName=“newdata.txt”; inputstringInpSrcDirectory=“SomeFolder”; inputstringInpDstDirectory=“OtherFolder”; //+——————————————————————+ //| Script program start function | //+——————————————————————+ voidOnStart() { string local=TerminalInfoString(TERMINAL_DATA_PATH); string common=TerminalInfoString(TERMINAL_COMMONDATA_PATH); //— get file paths string src_path=InpSrcDirectory+“//”+InpSrcName; string 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!”); }