;The program as ran %n thimes. #include #include $program = "Example" Runscript() func Runscript() ;Ftp: $sServer = "ftpupload.net" $sUsername = "xxx" $sPass = "pass123" Local $hOpen = _FTP_Open("Example") ;Ftp connect: Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass) If @error Then MsgBox(16, "Error", "Unable to connect to server: Reason: " & @error) EndIf ;Set variable for file: $openfile = $program &".txt" ;Get the current execution number from the server. $abririnternet = _FTP_FileOpen ($hConn, "htdocs/runs/" &$program &".txt") If @error then MsgBox(0, "Error", "Cannot create file.") EndIf ;Read statistics from ftp: $getdata = _FTP_FileRead($abririnternet, 8) If @error then MsgBox(0, "Error", "Cannot get the data from the file.") EndIf ;Remove temp file: FileDelete($openfile) ;Write the current number of executions: $asRunned = FileWrite($openfile, $getdata) if @error then MsgBox(0, "Error", "Impossible to write") EndIf sleep(500) ;Now we read the file to add +1 $rundata = FileRead($openfile) ;Apply operations: $number = $rundata $number = $number + 1 ;Write the final result: $newrun = FileWrite($openfile, $number) sleep(1000) ;Close all: FileClose($openfile) _FTP_FileClose ($abririnternet) sleep(1000) ;Send the file with the sum of the new execution: $Enviararchivo = _FTP_FilePut ($hConn, $program &".txt", "htdocs/runs/" &$program &".txt") if @error then MsgBox(0, "Ops", "The file could not even be sent") EndIf MsgBox(0, "This program has been ran", $rundata &" Times") FileDelete($program &".txt") Local $iFtpc = _FTP_Close($hConn) Local $iFtpo = _FTP_Close($hOpen) EndFunc