Hallo zusammen,
es klingt vielleicht doof, aber könnte mir mal bitte jemand von euch sagen, ob in dem folgenden Script Fehler sind im Sinne von: Ich deklariere eine Variable oder so, und gebe sie nicht frei?
Ihr würdet mir echt sehr helfen. Danke im Vorraus.
Spoiler anzeigen
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Add_Constants=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)
OnAutoItExitRegister("_exit")
Global $aLVERSATZ_bot[1][3]
Global $aLVERSATZ_top[5][2]
Global $ablaufstatus
;#GUI 1
Global $aufgabenlistefenster = GUICreate("Aufgabenliste", 250, 390)
Global $zaehler_label = 0
Global $hzaehler_label = GUICtrlCreateLabel("0", 50, 72, 200, 20)
Global $aladeaktiveap_button = GUICtrlCreateButton("Lade aktive AP", 140, 40, 100, 30)
Global $astart_button = GUICtrlCreateButton("Start", 30, 5, 50, 30)
Global $astop_button = GUICtrlCreateButton("Stop", 30, 40, 50, 30)
GUISetState(@SW_SHOW, $aufgabenlistefenster)
[/autoit] [autoit][/autoit] [autoit];Aufgabenliste
GUICtrlSetOnEvent($aladeaktiveap_button, "lade_aktive_aps")
GUICtrlSetOnEvent($astart_button, "pruefe_ablauf")
GUICtrlSetOnEvent($astop_button, "beende_ablauf")
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit", $aufgabenlistefenster)
While 1
Sleep(100)
WEnd
Func lade_aktive_aps()
$aLVERSATZ_bot[0][0] = "0"
$aLVERSATZ_bot[0][1] = "18/01/2013 08:00:00"
$aLVERSATZ_bot[0][2] = "Test AP"
EndFunc ;==>lade_aktive_aps
Func pruefe_ablauf()
$ablaufstatus = True
AdlibRegister("vergleiche_zeitstempel", 1000)
EndFunc ;==>pruefe_ablauf
Func vergleiche_zeitstempel()
Local $a_row0, $naechste_geplante_startdatum, $aDatumForm
If UBound($aLVERSATZ_bot) = 0 Then
beende_ablauf()
Return 0
EndIf
$a_row0 = StringSplit($aLVERSATZ_bot[0][1], " ")
$naechste_geplante_startdatum = $a_row0[1]
$a_row0 = StringSplit($a_row0[2], ":")
$aDatumForm = StringSplit($naechste_geplante_startdatum, "/")
[/autoit] [autoit][/autoit] [autoit]If $aDatumForm[3] * 365 + $aDatumForm[2] * 30 + $aDatumForm[1] = @YEAR * 365 + @MON * 30 + @MDAY Then
If $a_row0[1] * 3600 + $a_row0[2] * 60 = @HOUR * 3600 + @MIN * 60 + @SEC Or $a_row0[1] * 3600 + $a_row0[2] * 60 < @HOUR * 3600 + @MIN * 60 + @SEC Then
$a_row0 = 0
$aDatumForm = 0
starte_ablauf()
EndIf
ElseIf $aDatumForm[3] * 365 + $aDatumForm[2] * 30 + $aDatumForm[1] < @YEAR * 365 + @MON * 30 + @MDAY Then
$a_row0 = 0
$aDatumForm = 0
starte_ablauf()
EndIf
$zaehler_label = $zaehler_label + 1
GUICtrlSetData($hzaehler_label, $zaehler_label)
$a_row0 = 0
$naechste_geplante_startdatum = 0
$aDatumForm = 0
EndFunc ;==>vergleiche_zeitstempel
Func starte_ablauf()
Local $sFehler, $sStatus, $ShellExecute
Local $aBatch[5][5] = [[1, 1, $aLVERSATZ_bot[0][1], "Dateien erzeugen", ""], _
[2, 2, $aLVERSATZ_bot[0][1], "Dateien von neu nach backup kopieren", ""], _
[3, 3, $aLVERSATZ_bot[0][1], "Dateien von neu nach alt kopieren", ""], _
[4, 4, $aLVERSATZ_bot[0][1], "Dateien verschieben", ""], _
[5, 5, $aLVERSATZ_bot[0][1], "_neu_einplanen", ""]]
ReDim $aLVERSATZ_top[5][2]
For $i = 0 To UBound($aBatch) - 1
$aLVERSATZ_top[$i][0] = $aBatch[$i][1] * 10
$aLVERSATZ_top[$i][1] = $aBatch[$i][3]
Next
For $i = 0 To UBound($aBatch) - 1
$sStatus = " ... wird gestartet"
If $aBatch[$i][4] = "" Then
$sFehler = " "
_schreibe_log($sFehler, $aBatch[$i][4], $sStatus)
$sFehler = "OK"
$sStatus = " ... ist beendet"
_schreibe_log($sFehler, $aBatch[$i][4], $sStatus)
Else
$sFehler = " "
_schreibe_log($sFehler, $aBatch[$i][4], $sStatus)
$ShellExecute = Run($aBatch[$i][4], "c:", @SW_HIDE)
If $ShellExecute <> 0 Then
$sFehler = "FEHLER"
$sStatus = " Es ist ein Fehler aufgetreten."
Else
$sFehler = "OK"
$sStatus = " ... ist beendet"
EndIf
_schreibe_log($sFehler, $aBatch[$i][4], $sStatus)
EndIf
If UBound($aLVERSATZ_top) = 1 Then
$aLVERSATZ_top[0][0] = ""
$aLVERSATZ_top[0][1] = ""
Else
_ArrayDelete($aLVERSATZ_top, 0)
EndIf
Next
Sleep(1000)
If UBound($aLVERSATZ_bot) = 1 Then
$aLVERSATZ_bot[0][0] = ""
$aLVERSATZ_bot[0][1] = ""
$aLVERSATZ_bot[0][2] = ""
Else
_ArrayDelete($aLVERSATZ_bot, 0)
EndIf
$sFehler = 0
$sStatus = 0
$ShellExecute = 0
$aBatch = 0
lade_aktive_aps()
EndFunc ;==>starte_ablauf
Func beende_ablauf()
AdlibUnRegister("vergleiche_zeitstempel")
$ablaufstatus = False
Return 0
EndFunc ;==>beende_ablauf
Func _exit()
Exit
EndFunc ;==>_exit
Func _schreibe_log($sFehler, $sBefehl, $sStatus)
Local $hfile
$hfile = FileOpen("log_woBATCHwoSQLwoLV.txt", 1)
FileWriteLine($hfile, "[" & @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC & "][" & $sFehler & "] " & $sBefehl & " " & $sStatus)
FileClose($hfile)
EndFunc ;==>_schreibe_log