Hallo Leute,
Ich habe mit meinem K8055 Programmer mal wieder ein Problem und zwar:
Wenn ich eine Aktion in "Aktion Hinzufügen" auswähle, und die Daten festlege und auf OK klicke, stehen in der ListView nicht nur "Aktion" sondern gleich andere auch, die ich garnicht ausgewählt habe.
Die IniSection "Aktion" wird davor ja aber immer gelöscht.
Was mache ich Falsch?
Mein Skript
#region includes ;########################
#include <k8055udf.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiStatusBar.au3>
#include <ListViewConstants.au3>
#include <ComboConstants.au3>
#endregion includes
;##########################################
Global $adressebin=""
Global $aktion="Programm erfolgreich gestartet"
Global $ini=@ScriptDir&"\logdatei.ini"
Global $title,$text,$probs,$outputlabel,$outputcombo,$onoutput,$offoutput
global $inisection2
IniDelete($ini,"log")
IniDelete($ini,"startdaten")
IniDelete($ini,"inputs")
IniDelete($ini,"outputs")
IniDelete($ini,"aktion")
IniWrite($ini,"log","Startdaten",@HOUR&":"&@MIN&":"&@SEC&":"&@MSEC&"-Datum:"&@MDAY&"."&@MON&"."&@YEAR)
#Region ### START Verbindungsform ### Form=
$verbindungsform = GUICreate("Verbindung", 184, 100, 190, 126, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_WINDOWEDGE))
$SK5 = GUICtrlCreateCheckbox("SK5", 24, 16, 41, 17)
$SK6 = GUICtrlCreateCheckbox("SK6", 128, 16, 41, 17)
$Adresse = GUICtrlCreateGroup("Adresse", 8, 0, 169, 41)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateLabel("<---------------->", 64, 16, 64, 17)
$Progress1 = GUICtrlCreateProgress(0, 80, 182, 17)
$mitboardverbinden = GUICtrlCreateButton("Mit K8055 Board verbinden", 8, 48, 171, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Verbindungsform ###
;##########################################
#Region ### START Hauptform ### Form=c:\users\jonathan verbeek\desktop\k8055 programmer\hauptform.kxf
$Form1_1 = GUICreate("K8055 Board Programmer Basicpack - created by button421", 519, 412, 187, 121)
$statusleiste = _GUICtrlStatusBar_Create($Form1_1)
Dim $statusleiste_PartsWidth[2] = [439, -1]
_GUICtrlStatusBar_SetParts($statusleiste, $statusleiste_PartsWidth)
_GUICtrlStatusBar_SetText($statusleiste, $aktion, 0)
_GUICtrlStatusBar_SetText($statusleiste, "Verbunden", 1)
$DigitaleEingaenge = GUICtrlCreateGroup("Digitale Eingänge", 8, 0, 169, 41)
$I1 = GUICtrlCreateCheckbox("I1", 16, 16, 25, 17)
$I2 = GUICtrlCreateCheckbox("I2", 48, 16, 25, 17)
$I3 = GUICtrlCreateCheckbox("I3", 80, 16, 25, 17)
$I4 = GUICtrlCreateCheckbox("I4", 112, 16, 25, 17)
$I5 = GUICtrlCreateCheckbox("I5", 144, 16, 25, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$DigitaleAusgaenge = GUICtrlCreateGroup("Digitale Ausgänge", 184, 0, 329, 41)
$O1 = GUICtrlCreateCheckbox("O1", 192, 16, 33, 17)
$O2 = GUICtrlCreateCheckbox("O2", 232, 16, 33, 17)
$O3 = GUICtrlCreateCheckbox("O3", 272, 16, 33, 17)
$O4 = GUICtrlCreateCheckbox("O4", 312, 16, 33, 17)
$O5 = GUICtrlCreateCheckbox("O5", 352, 16, 33, 17)
$O6 = GUICtrlCreateCheckbox("O6", 392, 16, 33, 17)
$O7 = GUICtrlCreateCheckbox("O7", 432, 16, 33, 17)
$O8 = GUICtrlCreateCheckbox("O8", 472, 16, 33, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$ListView1 = GUICtrlCreateListView("Aktionen", 8, 48, 506, 310)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 502)
$addaktion = GUICtrlCreateButton("Aktion hinzufügen", 8, 360, 107, 25, $WS_GROUP)
$delaktion = GUICtrlCreateButton("Aktion löschen", 120, 360, 91, 25, $WS_GROUP)
$anleitung = GUICtrlCreateButton("Anleitung für Experimente", 216, 360, 131, 25, $WS_GROUP)
$hilfe = GUICtrlCreateButton("Hilfe und Info", 352, 360, 75, 25, $WS_GROUP)
$beenden = GUICtrlCreateButton("Beenden", 432, 360, 75, 25, $WS_GROUP)
GUISetState(@SW_HIDE)
#EndRegion ### END Hauptform ###
;#######################################
#Region ### START Aktion hinzufügen ### Form=
$actionadd = GUICreate("Aktion hinzufügen", 246, 187, 192, 124, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_WINDOWEDGE))
$Aktionlabel = GUICtrlCreateLabel("Aktion:", 8, 8, 37, 17)
$aktioncombo = GUICtrlCreateCombo("", 48, 8, 193, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Meldung anzeigen|Digitalen Ausgang ein/ausschalten|Abfrage ob Digitaler Eingang ein")
$probs = GUICtrlCreateGroup("Einstellungen für Aktion festlegen", 8, 32, 233, 121)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$cancelactionadd = GUICtrlCreateButton("Abbrechen", 168, 160, 75, 25, $WS_GROUP)
$okactionadd = GUICtrlCreateButton("OK", 88, 160, 75, 25, $WS_GROUP)
GUISetState(@SW_HIDE)
#EndRegion ### END Aktion hinzufügen ###
;#######################################
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3, $beenden
Exit
Case $SK5
If BitAND(GUICtrlRead($SK5),$GUI_CHECKED) Then
$adressebin = "SK5/"
EndIf
Case $SK6
If BitAND(GUICtrlRead($SK6),$GUI_CHECKED) Then
$adressebin = "SK6/"
EndIf
Case $mitboardverbinden
If GUICtrlRead($adressebin) = "SK5/SK6/" Then
USB_DLLOpen()
initial_board(0)
GUICtrlSetState($Progress1, 100)
MsgBox(64,"Info","Mit Board verbunden!")
GUISetState(@SW_SHOW, $Form1_1)
GUISetState(@SW_HIDE, $verbindungsform)
ElseIf GUICtrlRead($adressebin) = "SK6/" Then
USB_DLLOpen()
initial_board(1)
GUICtrlSetState($Progress1, 100)
MsgBox(64,"Info","Mit Board verbunden!")
GUISetState(@SW_SHOW, $Form1_1)
GUISetState(@SW_HIDE, $verbindungsform)
ElseIf GUICtrlRead($adressebin) = "SK5/" Then
USB_DLLOpen()
initial_board(2)
GUICtrlSetState($Progress1, 100)
MsgBox(64,"Info","Mit Board verbunden!")
GUISetState(@SW_SHOW, $Form1_1)
GUISetState(@SW_HIDE, $verbindungsform)
Else
USB_DLLOpen()
initial_board(3)
GUICtrlSetState($Progress1, 100)
MsgBox(64,"Info","Mit Board verbunden!")
GUISetState(@SW_SHOW, $Form1_1)
GUISetState(@SW_HIDE, $verbindungsform)
EndIf
$msg = MsgBox(36,"Du weißt es?","Weißt du wie das Programm funktioniert? Wenn ja, klick auf Nein!"&@CRLF&"Brauchst du Hilfe?")
If $msg = 7 Then
MsgBox(64,"OK","Viel Spass noch!")
ElseIf $msg = 6 Then
MsgBox(64,"Hilfe","Also:"&@CRLF&"Als erstes musst du die Eingänge und Ausgänge die du verwenden willst auswählen,"&@CRLF&"dann klickst du auf Neue Aktion und wählst den Aktionstyp aus. Wenn du dabei Hilfe brauchst, schreibe eine Mail an:"&@CRLF&"jverbeek@freenet.de"&@CRLF&"Drücke F2 um Sleep einzusetzen.")
EndIf
;Eingänge
Case $I1
If BitAND(GUICtrlRead($I1),$GUI_CHECKED)Then
IniDelete($ini,"inputs")
IniWrite($ini,"inputs","I1","1")
Else
IniDelete($ini,"inputs")
IniWrite($ini,"inputs","I1","0")
EndIf
Case $I2
If BitAND(GUICtrlRead($I2),$GUI_CHECKED)Then
IniDelete($ini,"inputs","I2")
IniWrite($ini,"inputs","I2","1")
Else
IniDelete($ini,"inputs","I2")
IniWrite($ini,"inputs","I2","0")
EndIf
Case $I3
If BitAND(GUICtrlRead($I3),$GUI_CHECKED)Then
IniDelete($ini,"inputs","I3")
IniWrite($ini,"inputs","I3","1")
Else
IniDelete($ini,"inputs","I3")
IniWrite($ini,"inputs","I3","0")
EndIf
Case $I4
If BitAND(GUICtrlRead($I4),$GUI_CHECKED)Then
IniDelete($ini,"inputs","I4")
IniWrite($ini,"inputs","I4","1")
Else
IniDelete($ini,"inputs","I4")
IniWrite($ini,"inputs","I4","0")
EndIf
Case $I5
If BitAND(GUICtrlRead($I5),$GUI_CHECKED)Then
IniDelete($ini,"inputs","I5")
IniWrite($ini,"inputs","I5","1")
Else
IniDelete($ini,"inputs","I5")
IniWrite($ini,"inputs","I5","0")
EndIf
;Ausgänge
Case $O1
If BitAND(GUICtrlRead($O1),$GUI_CHECKED)Then
IniDelete($ini,"outputs","O1")
IniWrite($ini,"outputs","O1","1")
Else
IniDelete($ini,"outputs","O2")
IniWrite($ini,"outputs","O1","0")
EndIf
Case $O2
If BitAND(GUICtrlRead($O2),$GUI_CHECKED)Then
IniDelete($ini,"outputs","O2")
IniWrite($ini,"outputs","O2","1")
Else
IniDelete($ini,"outputs","O2")
IniWrite($ini,"outputs","O2","0")
EndIf
Case $O3
If BitAND(GUICtrlRead($O3),$GUI_CHECKED)Then
IniDelete($ini,"outputs","O3")
IniWrite($ini,"outputs","O3","1")
Else
IniDelete($ini,"outputs","O3")
IniWrite($ini,"outputs","O3","0")
EndIf
Case $O4
If BitAND(GUICtrlRead($O4),$GUI_CHECKED)Then
IniDelete($ini,"outputs","O4")
IniWrite($ini,"outputs","O4","1")
Else
IniDelete($ini,"outputs","O4")
IniWrite($ini,"outputs","O4","0")
EndIf
Case $O5
If BitAND(GUICtrlRead($O5),$GUI_CHECKED)Then
IniDelete($ini,"outputs","O5")
IniWrite($ini,"outputs","O5","1")
Else
IniDelete($ini,"outputs","O5")
IniWrite($ini,"outputs","O5","0")
EndIf
Case $O6
If BitAND(GUICtrlRead($O6),$GUI_CHECKED)Then
IniDelete($ini,"outputs","O6")
IniWrite($ini,"outputs","O6","1")
Else
IniDelete($ini,"outputs","O6")
IniWrite($ini,"outputs","O6","0")
EndIf
Case $O7
If BitAND(GUICtrlRead($O7),$GUI_CHECKED)Then
IniDelete($ini,"outputs","O7")
IniWrite($ini,"outputs","O7","1")
Else
IniDelete($ini,"outputs","O7")
IniWrite($ini,"outputs","O7","0")
EndIf
Case $O8
If BitAND(GUICtrlRead($O8),$GUI_CHECKED)Then
IniDelete($ini,"outputs","O8")
IniWrite($ini,"outputs","O8","1")
Else
IniDelete($ini,"outputs","O8")
IniWrite($ini,"outputs","O8","0")
EndIf
Case $addaktion
GUISetState(@SW_SHOW, $actionadd)
GUICtrlDelete($probs)
Case $aktioncombo
If GUICtrlRead($aktioncombo) = "Meldung anzeigen" Then
$probs = GUICtrlCreateGroup("Einstellungen für Meldung festlegen", 8, 32, 233, 121)
$title = GUICtrlCreateInput("Titel der Meldung",17,45,217,21)
$text = GUICtrlCreateInput("Text der Meldung",17,70,217,73)
IniDelete($ini,"aktion")
IniWrite($ini,"aktion","Msg","1")
EndIf
If GUICtrlRead($aktioncombo) = "Digitalen Ausgang Ein/Ausschalten" Then
GUICtrlDelete($probs)
GUICtrlDelete($title)
GUICtrlDelete($text)
$probs = GUICtrlCreateGroup("Einstellungen für Ausgang festlegen", 8, 32, 233, 121)
$outputlabel = GUICtrlCreateLabel("Ausgang:",11,80,49,17)
$outputcombo = GUICtrlCreateCombo("",64,80,153,17, $CBS_DROPDOWNLIST)
$inisection = IniReadSection($ini, "outputs")
For $i = 1 To $inisection[0][0]
If $inisection[$i][1] Then GUICtrlSetData($outputcombo, $inisection[$i][0])
Next
IniDelete($ini,"aktion")
IniWrite($ini,"aktion","SetDigitalChannel","1")
$onoutput = GUICtrlCreateRadio("Einschalten",20,115,81,17,$BS_AUTORADIOBUTTON)
$offoutput = GUICtrlCreateRadio("Ausschalten",20,130,81,17, $BS_AUTORADIOBUTTON)
EndIf
If GUICtrlRead($aktioncombo) = "Abfrage ob Digitaler Eingang ein" Then
GUICtrlDelete($probs)
GUICtrlDelete($title)
GUICtrlDelete($text)
GUICtrlDelete($probs)
GUICtrlDelete($outputlabel)
GUICtrlDelete($outputcombo)
GUICtrlDelete($onoutput)
GUICtrlDelete($offoutput)
$probs = GUICtrlCreateGroup("Einstellung für Abfrage festlegen",8,32,233,121)
$inputlabel = GUICtrlCreateLabel("Eingang:",8,100,49,17)
$inputcombo = GUICtrlCreateCombo("",72,100,145,25,$CBS_DROPDOWNLIST)
$inisection2 = IniReadSection($ini, "inputs")
For $i_2 = 1 To $inisection2[0][0]
If $inisection2[$i_2][1] Then GUICtrlSetData($inputcombo, $inisection2[$i_2][0])
Next
IniDelete($ini,"aktion")
IniWrite($ini,"aktion","ReadDigitalChannel","1")
EndIf
Case $onoutput
If BitAND(GUICtrlRead($onoutput),$GUI_CHECKED)Then
SetError("an")
EndIf
Case $offoutput
If BitAND(GUICtrlRead($offoutput),$GUI_CHECKED)Then
SetError("aus")
EndIf
Case $okactionadd
If IniRead($ini,"aktion","Msg","1")Then
IniDelete($ini,"aktion","SetDigitalChannel")
IniDelete($ini,"aktion","ReadDigitalChannel")
GUISetState(@SW_HIDE,$actionadd)
GUICtrlCreateListViewItem("Meldung anzeigen("&GUICtrlRead($title)&","&GUICtrlRead($text)&")",$ListView1)
EndIf
If IniRead($ini,"aktion","SetDigitalChannel","1")Then
IniDelete($ini,"aktion","Msg")
IniDelete($ini,"aktion","ReadDigitalChannel")
GUISetState(@SW_HIDE,$actionadd)
If @error = "an" Then
GUICtrlCreateListViewItem("Digitalen Ausgang setzen("&GUICtrlRead($outputcombo)&",an)",$ListView1)
Else
GUICtrlCreateListViewItem("Digitalen Ausgang setzen("&GUICtrlRead($outputcombo)&",aus)",$ListView1)
EndIf
EndIf
If IniRead($ini,"aktion","ReadDigitalChannel","1")Then
IniDelete($ini,"aktion","SetDigitalChannel")
IniDelete($ini,"aktion","Msg")
GUICtrlCreateListViewItem(".: Ist Input "&GUICtrlRead($inputcombo)&" ein? Wenn ja, dann :.",$ListView1)
IniWrite($ini,"aktiondetails","ReadDigitalInput-Input",GUICtrlRead($inputcombo))
EndIf
EndSwitch
WEnd
MfG
button421