Hi, sorry für die Verwirrung. Hab mal weiter rumprobiert. Hier der neue Code. Meine Idee war, dass der Rückgabewert in $global aus der For-Schleife gespeichert wird. Blöderweise kommt an der Stelle " If $global = "OK" then" die Fehlermeldung, dass die Variable $global nicht deklariert sei...
An sich ist es nicht anderes als das hier.. Nur, dass es in reduzierter Form funktioniert, im Skript unten aus irgendwelchen Gründen nicht..
Code
$confirmBooking = MsgBox(3, "", "Hallo")
If $confirmBooking = $IDYES Then
For $z = 0 to 100 -1
If $z=30 then
$global = "30"
Else
EndIf
Next
Else
EndIf
If $global = "30" then
MsgBox(0,"", $global)
Else
MsgBox(0, "", "Klappt nicht")
EndIf
Alles anzeigen
Code
Case $bBook
If GUICtrlRead($iNameBooking) = "" then
MsgBox(0, "Error", "Add your name.")
Else
$riName = GuiCtrlRead($iName)
$riDateFrom = GUICtrlRead($iDateFrom)
$riHourB = GUICtrlRead($iHourB)
$riMinuteB = GUICtrlRead($iMinuteB)
$riDateTo = GUICtrlRead($iDateTo)
$riHourE = GUICtrlRead($iHourE)
$riMinuteE = GUICtrlRead($iMinuteE)
$riNameBooking = GUICtrlRead($iNameBooking)
$confirmBooking = MsgBox(3, "Confirm", "Book " & $riNameInstrument & @CRLF & "from " & $riDateFrom & ", " & $riHourB & ":" & $riMinuteB & @CRLF & "to " & $riDateTo & ", " & $riHourE & ":" & $riMinuteE & " ?")
If $confirmBooking = $IDYES Then
$iDateCalc = _DateDiff("n", $riDateFrom & " " & $riHourB & ":" & $riMinuteB & ":00", $riDateTo & " " & $riHourE & ":" & $riMinuteE & ":00")
If $iDateCalc <0 then
MsgBox(0, "Error", "Please check your booking entry.")
ElseIf $iDateCalc = 0 then
MsgBox(0, "Error", "Please check your booking entry.")
ElseIf _DateDiff("n", _NowCalc(), $riDateTo & " " & $riHourE & ":" & $riMinuteE & ":00") <0 then
MsgBox(0, "Error", "Your booking lies in the past. Check your entry.")
Else
$k = 0
For $z = 0 to _GUICtrlListView_GetItemCount($iListViewBooking)-1
$aColumn1= _GUICtrlListView_GetItemText($iListViewBooking, $k)
$aColumn2= _GUICtrlListView_GetItemText($iListViewBooking, $k, 1)
$DateDiffFrom1 = _DateDiff("n", $riDateFrom & " " & $riHourB & ":" & $riMinuteB & ":00", $aColumn1)
$DateDiffTo1 = _DateDiff("n", $riDateTo & " " & $riHourE & ":" & $riMinuteE & ":00", $aColumn2)
$DateDiffFrom2 = _DateDiff("n", $riDateFrom & " " & $riHourB & ":" & $riMinuteB & ":00", $aColumn2)e
$DateDiffTo2 = _DateDiff("n", $riDateTo & " " & $riHourE & ":" & $riMinuteE & ":00", $aColumn1)
If $DateDiffFrom1 >=0 And $DateDiffTo2 >=0 Then ;(1) OK
$global = "OK"
ElseIf $DateDiffFrom1 >=0 And $DateDiffTo2 <=0 Then ;(2)
$global = "Error"
Exitloop
ElseIf $DateDiffFrom2 >=0 And $DateDiffTo1 <=0 Then ;(3)
$global = "ERROR"
Exitloop
ElseIf $DateDiffFrom2 <=0 And $DateDiffTo1 <=0 Then ;(4) OK
$global = "OK"
ElseIf $DateDiffFrom1 >=0 And $DateDiffTo1 <=0 Then ;(5)
$global = "ERROR"
Exitloop
ElseIf $DateDiffFrom1 >=0 And $DateDiffTo1 >=0 Then ;(6)5
$global = "ERROR"
Exitloop
Else
EndIf
$k+=1
Next
EndIf
EndIf
If $global = "OK" then
$Bookingfile = FileOpen("documentation\Booking\" & $riNameInstrument & ".txt", 1)
FileWrite($Bookingfile, @CRLF & $riDateFrom & " " & $riHourB & ":" & $riMinuteB & "|" & $riDateTo & " " & $riHourE & ":" & $riMinuteE & "|" & $riNameBooking)
FileClose($Bookingfile)
_GUICtrlListView_DeleteAllItems($iListViewBooking)
_GUICtrlListView_DeleteAllItems($iListViewBooking2)
For $z = 2 to 100 -1
$LineBooking = FileReadline($idataBooking, $z)
$sSeperator = "|"
$SubItems = StringSplit($LineBooking, $sSeperator)
If $LineBooking = "" Then
Else
$iDateCalc = _DateDiff("n", _NowCalc(),$SubItems[2])
If $iDateCalc >= 0 Then
$NewBooking = _GUICtrlListView_AddItem($iListViewBooking, $SubItems[1])
For $n = 2 to $SubItems[0]
_GUICtrlListView_AddSubItem($iListViewBooking, $NewBooking, $SubItems[$n], $n - 1)
Next
Else
$NewBooking = _GUICtrlListView_AddItem($iListViewBooking2, $SubItems[1])
For $n = 2 to $SubItems[0]
_GUICtrlListView_AddSubItem($iListViewBooking2, $NewBooking, $SubItems[$n], $n - 1)
Next
EndIf
EndIf
Next
Else
MsgBox(0, "Error", "Check your entry.")
EndIf
EndIf
EndSwitch
WEnd
Alles anzeigen