MathiasG Posted July 17, 2014 Posted July 17, 2014 (edited) Hey everyone, i have a Problem with my debugroutine I wrote my self and used as it is in a lot of projects.... The Opt("MustDeclareVars",1) is set and there is no Error when creating the script... But when I want to run ist, it says the following: It has to be line 151 to 157, when I delete them everything is okay,... Does somebody have any idea what it could be?? Thanks to all reading this... Mathias [update] After the Update to v3.3.12.0 the same just now the Error is in Line 2902 .... [/update] expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=backup_32_v2.exe #AutoIt3Wrapper_Outfile_x64=backup_64_v2.exe #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_Fileversion=0.0.0.42 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y #AutoIt3Wrapper_Res_Language=1031 #AutoIt3Wrapper_AU3Check_Parameters=-d #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** Opt("MustDeclareVars",1) #include <file.au3> Local $debug = readini("debug.ini") debughandling("VAR",$debug) Local $debugzahl = 1 Local $writelogzahl = 1 Local $debugmsg = "" Local $head = "" Local $i = readini("datenbank_anzahl.ini") debughandling("VAR",$i) Local $z = 0 Local $logpath = readini("script_logpath.ini") debughandling("VAR",$logpath) Local $format = "" Local $pfad = "" Local $tage = readini("backup_logs_anzahl_tage.ini") debughandling("VAR",$tage) Local $speicherort_backup = readini("backup_speicherort.ini") debughandling("VAR",$speicherort_backup) Local $speicherort_logs = readini("backup_speicherort_logs.ini") debughandling("VAR",$speicherort_logs) Local $mysqladmin = readini("mysqladmin-exe.ini") debughandling("VAR",$mysqladmin) Local $mysqldump = readini("mysqldump-exe.ini") debughandling("VAR",$mysqldump) Exit Local $db_user = "Any" Local $db_pw = "Anything" Local $db_admin = "Something" Local $db_admin_pw = "Somemore" Local $port="NUMBER" Local $date = @YEAR&"_"&@MON&"_"&@MDAY Local $result If DirGetSize($speicherort_backup) == -1 Then if $debug == 1 Then debughandling("Ordner gefaket","Es würde der Ordner generiert:"&$speicherort_backup&"") Else DirCreate($speicherort_backup) debughandling("Ordner generiert","Es wurde der Ordner generiert:"&$speicherort_backup&"") EndIf EndIf Local $anzahl_db = 34 $result = RunWait('"'&$mysqladmin&'" -u'& $db_admin &' -p'& $db_admin_pw &' stop-slave') debughandling("Result Stop Slave","Ergebniss: "&$result&"") if $debug == 1 Then Else $result = RunWait('DelAge32 "G:\Datenbanksicherung\01-30\" 1 /recurse >> G:\logs\loschen_der_Backups_'&$date&'.txt') debughandling("Result Delete old Folder","Ergebniss: "&$result&"") $result = RunWait('DelAge32 "G:\logs\*.txt" 14 /recurse') debughandling("Result Delete Logs","Ergebniss: "&$result&"") EndIf Do debughandling("i Vorher",$i) if $i < 10 Then $z = "0"&$i&"" Else $z = $i EndIf debughandling("Z nachher",$z) Local $batchfile = _TempFile("SOMEPATH","bat_",".bat",7); Local $file = FileOpen($batchfile, 2) If $file = -1 Then MsgBox(0, "Error", "Kann Batch-Datei nicht ändern.") Exit EndIf If $z == "00" Then $z = "SOMETHIMG" if $debug==1 Then debughandling(SOMETHIMG) Else Local $command = (SOMETHIMG) FileWrite($file, $command ) FileClose($file) Local $pid = RunWait($batchfile) ProcessWaitClose($pid) ;FileDelete($batchfile) EndIf Else if $debug==1 Then debughandling(SOMETHIMG) Else Local $command = (SOMETHIMG) ;FileWrite($file,"setlocal disabledelayedexpansion" & @CRLF) FileWrite($file, $command ) FileClose($file) Local $pid = RunWait($batchfile) ProcessWaitClose($pid) FileDelete($batchfile) EndIf EndIf $i = $i + 1 Until $i == $anzahl_db $result = RunWait('"'&$mysqladmin&'" -u'& $db_admin &' -p'& $db_admin_pw &' start-slave') debughandling("Result Start Slave","Ergebniss: "&$result&"") ; DEBUGING Func readini($input) ; Open the file for reading and store the handle to a variable. Local $file = FileOpen(@ScriptDir &"\ini\"& $input,0) If $file = -1 Then MsgBox(0, "", "An error occurred when opening the file: "& $input ) Return False Else ; Read the contents of the file using the handle returned by FileOpen. Local $out = FileRead($file) If $out = -1 Then MsgBox(0, "", "An error occurred when reading the file: "& $input) Return False Else Return $out EndIf EndIf ; Close the handle returned by FileOpen. FileClose($file) EndFunc ;Filedelete Func removefiles($format,$pfad,$tage) RunWait('forfiles /S /M *.'& $format &' /D -4 /C "cmd /c del @path"',$pfad) EndFunc ;DEBUGING Func debughandling($head,$debugmsg) If $debug == 1 Then MsgBox(0, "DEBUG Launcher", "Schritt: " & $debugzahl & @CRLF & "Head: " & $head & @CRLF & "Meldung: "& @CRLF & $debugmsg) $debugzahl = $debugzahl+1 EndIf EndFunc ;WriteLog Func write_log($head,$debugmsg) _FileWriteLog($logpath&"log_"&@YEAR&"_"&@MON&"_"&@MDAY&".log", "DEBUG Launcher", "Schritt: " & $writelogzahl & @CRLF & "Head: " & $head & @CRLF & "Meldung: "& @CRLF & $debugmsg) EndFunc Edited July 17, 2014 by MathiasG
jchd Posted July 17, 2014 Posted July 17, 2014 (edited) At line 15 you invoke the function debughandling() but at this stage the interpretor hasn't seen yet the line 16 where the variable $debugzahl (used in that function) is declared. Since this variable seems to be used only in that function, I'd advise declaring it inside the function with attribute Static. Edited July 17, 2014 by jchd This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now