Hi,
I'm facing a problem to get the file compile properly. It indicate with error:
$iFlag: possibly used before declaration,
$iFlag: undeclared global variable.
Below is my code.
#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <File.au3>
Global $file, $sPath, $hFile, $vPath, $sDrive
$file = FileOpen("backup-path.txt", 0) ; Open the directory file in read only mode. The directory path until $sPath only.
$hFile = FileOpen("backup-sync.log", 1) ; Open the logfile in write mode.
; Check if file opened for reading OK
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
ElseIf FileExists("I:\") Then
sync()
Else
MsgBox(0, "Error", "I:\ drive not found")
_FileWriteLog($hFile, 'I:\ drive not found', $iFlag <> -1) ; Write to the logfile with section ending
_FileWriteLog($hFile, '*****', $iFlag <> -1) ; Write to the logfile with section ending
EndIf
Func sync()
$vPath = InputBox("Define folder name", "Enter folder name", "WWxx dd-mm-yyyy", "", 200, 130)
SplashTextOn("", "Syncing files. Please wait.", 250, 50, -1, -1, 16, "", 10)
; Read in lines of text until the EOF is reached
While 1
DirCreate("I:\" & $vPath)
Local $line = FileReadLine($file)
If @error = -1 Then ExitLoop
FileCopy($line, "I:\" & $vPath, 1)
_FileWriteLog($hFile, 'Copied;'&@ComputerName&';'&$line, $iFlag <> -1) ; Write to the logfile passing the filehandle returned by FileOpen.
_FileWriteLog($hFile, '*****', $iFlag <> -1) ; Write to the logfile with section ending.
FileClose($hFile) ; Close the log file.
FileClose($file) ; Close the directory file.
Sleep(3000)
WEnd
SplashOff()
MsgBox(0,"", "Sync completed.")
EndFunc