#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Vokabeltrainer 0.1", 297, 130, 532, 287)
$Label1 = GUICtrlCreateLabel("Vokabel", 56, 16)
$Input1 = GUICtrlCreateInput("Übersetzung", 16, 56, 121, 21)
$Button1 = GUICtrlCreateButton("OK", 16, 88, 121, 25)
$Button2 = GUICtrlCreateButton("Liste anzeigen", 152, 14, 121, 25)
$Button3 = GUICtrlCreateButton("Neue Vokabel", 152, 54, 121, 25)
$Button4 = GUICtrlCreateButton("Sprache", 152, 88, 121, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $temparray[2]
_update()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_check()
Case $Button2
;_list()
Case $Button3
_new()
Case $Button4
;_lang()
EndSwitch
WEnd
Func _new()
$put = InputBox("Vokabel","Bitte die Vokabel in Deutsch eingeben")
$put2 = InputBox("Vokabel","Übersetzung")
$vokread = IniReadSection("Vok.ini","Vok")
If @error Then
IniWrite("Vok.ini","Vok","Vok",$put & "/" & $put2)
Else
IniWrite("Vok.ini","Vok","Vok" & $vokread[0][0]+1, $put & "/" & $put2)
EndIf
EndFunc
Func _update()
$tok = IniReadSection("Vok.ini","Vok")
$z =Random(2,$tok[0][0],1)
$tak = IniRead("Vok.ini","Vok","Vok" & $z,"")
$tstring = StringSplit($tak,"/")
$z2 = Random(1,2,1)
If $z2 = 1 Then
$k = 2
ElseIf $z2 = 2 Then
$k = 1
EndIf
Global $temparray[0] = $tstring[$z2]
Global $temparay[1] = $tstring[$k]
GUICtrlSetData($Label1,$tstring[$z2])
EndFunc
Func _check()
$vokread = IniReadSection("Vok.ini","Vok")
$r1 = IniRead("Vok.ini","Vok","Vok" & $vokread[0][0]+1,"")
$r2 = StringSplit($r1,"/")
$r3 = GUICtrlRead($Input1)
If $r2 = $temparray[0] Then
If $r3 = $temparray[1] Then
GUICtrlSetData($Label1,"Richtig")
_update()
Else
GUICtrlSetData($Label1,"Falsch")
_update()
EndIf
ElseIf $r2 = $temparray[0] Then
If $r3 = $temparray[1] Then
GUICtrlSetData($Label1,"Richtig")
_update()
Else
GUICtrlSetData($Label1,"Falsch")
_update()
EndIf
EndIf
EndFunc
Sehr unübersichtlich, ich weiß xD
Also, es geht um _update() und _check()...
Bzw. _update funktioniert soweit, aber ich will die Werte aus $tstring für das ganze Script speichern...
Und _check() funktioniert iwie garnicht...
mipez wenn du bock hast, erkläre mir pn was dein script machen soll udn alles drum und dran, bzw. was change und update GENAU machen soll und ich baus dir ;O
$tstring speichert unter update (bzw. soll es zumindest) die aktuellen Werte aus Random.
Diese will ich dann bei anderen Funktionen verwenden... und nein, global hat nicht funktioniert xD
EDIT: Ich muss erstmal das Script überholen... iwie hab ich da nur Scheiß geschrieben xD
Code:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Vokabeltrainer 0.1", 297, 130, 532, 287)
$Label1 = GUICtrlCreateLabel("Vokabel", 56, 16)
$Input1 = GUICtrlCreateInput("Übersetzung", 16, 56, 121, 21)
$Button1 = GUICtrlCreateButton("OK", 16, 88, 121, 25)
$Button2 = GUICtrlCreateButton("Liste anzeigen", 152, 14, 121, 25)
$Button3 = GUICtrlCreateButton("Neue Vokabel", 152, 54, 121, 25)
$Button4 = GUICtrlCreateButton("Sprache", 152, 88, 121, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $temparray[1]
Global $tstring
_update()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_check()
Case $Button2
;_list()
Case $Button3
_new()
Case $Button4
;_lang()
EndSwitch
WEnd
Func _new()
$put = InputBox("Vokabel","Bitte die Vokabel in Deutsch eingeben")
$put2 = InputBox("Vokabel","Übersetzung")
$vokread = IniReadSection("Vok.ini","Vok")
If @error Then
IniWrite("Vok.ini","Vok","Vok",$put & "/" & $put2)
Else
IniWrite("Vok.ini","Vok","Vok" & $vokread[0][0]+1, $put & "/" & $put2)
EndIf
EndFunc
Func _update()
$tok = IniReadSection("Vok.ini","Vok")
$z =Random(2,$tok[0][0],1)
$tak = IniRead("Vok.ini","Vok","Vok" & $z,"")
$tstring = StringSplit($tak,"/")
$z2 = Random(1,2,1)
If $z2 = 1 Then
$temparray[0] = 1
ElseIf $z2 = 2 Then
$temparray[0] = 2
EndIf
GUICtrlSetData($Label1,$tstring[$z2])
EndFunc
Func _check()
$r3 = GUICtrlRead($Input1)
If $temparray[0] <> 1 Then
If $r3 = $tstring[1] Then
GUICtrlSetData($Label1,"Richtig")
_update()
Else
GUICtrlSetData($Label1,"Falsch")
_update()
EndIf
ElseIf $temparray[0] <> 2 Then
If $r3 = $tstring[2] Then
GUICtrlSetData($Label1,"Richtig")
_update()
Else
GUICtrlSetData($Label1,"Falsch")
_update()
EndIf
EndIf
EndFunc
So, jetzt gehts nur noch um _check()...
Es soll überprüfen ob bei _update() $z2 1 oder 2 ausgegeben hat und diese dann auf $tstring übertragen. Dann einfach noch das Label ändern und wieder update()...
Allerdings springt es immer weiter, egal ob ich MsgBoxen einbaue, werden einfach übersprungen oô
wenn du das script das erste mal startest ist die vok.ini nocht nicht vorhanden. Das Script bricht dann bei zugriff auf das $tok[0][0] array zusammen. Checke anhand @error ob überhaupt ein array zurückgegben wird.
Der nächste fehler ist in Zeile 60 "GUICtrlSetData($Label1,$tstring[$z2])". Weil du den .ini file falsch ausließt.
Hier di update func. Hab nur nen par msg bocen gesetz so das dus selber debuggen kannst.
Code:
#include <Array.au3>
Func _update()
$tok = IniReadSection("Vok.ini","Vok")
If not @error Then
$z =Random(2,$tok[0][0],1)
MsgBox("","1",$z)
$tak = IniRead("Vok.ini","Vok","Vok" & $z,"")
MsgBox("","2",$tak)
$tstring = StringSplit($tak,"/")
_ArrayDisplay($tstring)
$z2 = Random(1,2,1)
If $z2 = 1 Then
$temparray[0] = 1
ElseIf $z2 = 2 Then
$temparray[0] = 2
EndIf
GUICtrlSetData($Label1,$tstring[$z2])
EndIf
EndFunc
wenn du das script das erste mal startest ist die vok.ini nocht nicht vorhanden. Das Script bricht dann bei zugriff auf das $tok[0][0] array zusammen. Checke anhand @error ob überhaupt ein array zurückgegben wird.
Der nächste fehler ist in Zeile 60 "GUICtrlSetData($Label1,$tstring[$z2])". Weil du den .ini file falsch ausließt.
Hier di update func. Hab nur nen par msg bocen gesetz so das dus selber debuggen kannst.
Code:
#include <Array.au3>
Func _update()
$tok = IniReadSection("Vok.ini","Vok")
If not @error Then
$z =Random(2,$tok[0][0],1)
MsgBox("","1",$z)
$tak = IniRead("Vok.ini","Vok","Vok" & $z,"")
MsgBox("","2",$tak)
$tstring = StringSplit($tak,"/")
_ArrayDisplay($tstring)
$z2 = Random(1,2,1)
If $z2 = 1 Then
$temparray[0] = 1
ElseIf $z2 = 2 Then
$temparray[0] = 2
EndIf
GUICtrlSetData($Label1,$tstring[$z2])
EndIf
EndFunc
_update funktionierte einwandfrei xD
Und die Vok.ini erstellts automatisch, wenn keine vorhanden is.
_check funktioniert nur halt nicht richtig...
Dammig nochmal... es klappt alles, nur das Label muss ich auf Sleep setzen, sonst wirds nich angezeigt xDDD
Wenn nur Vok und Vok2 drinne stehen -> Crash... Vok is nur als Platzhalter gedacht, damit es über IniReadSection keine Probleme bekommt...
EDIT:
Also ich hab mal n paar Änderungen vorgenommen, allerdings stellt sich mir immernoch das Problem mit der .ini...
Code:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Vokabeltrainer 0.1", 297, 130, 532, 287)
$Label1 = GUICtrlCreateLabel("", 56, 16,100,20)
$Input1 = GUICtrlCreateInput("", 16, 56, 121, 21)
$Button1 = GUICtrlCreateButton("OK", 16, 88, 121, 25)
$Button2 = GUICtrlCreateButton("Liste anzeigen", 152, 14, 121, 25)
$Button3 = GUICtrlCreateButton("Neue Vokabel", 152, 54, 121, 25)
$Button4 = GUICtrlCreateButton("Sprache", 152, 88, 121, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $temparray[1]
Global $tstring
;_update()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_check()
Case $Button2
;_list()
Case $Button3
_new()
Case $Button4
;_lang()
EndSwitch
WEnd
Func _new()
$put = InputBox("Vokabel","Bitte die Vokabel in Deutsch eingeben")
$put2 = InputBox("Vokabel","Übersetzung")
$vokread = IniReadSection("Vok.ini","Vok")
If @error Then
MsgBox(0,"Neue .ini", "Es wird eine neue Vok.ini erstellt, bitte Neueingabe wiederholen")
IniWrite("Vok.ini","Vok","Vok","Dump/Dump")
Else
IniWrite("Vok.ini","Vok","Vok" & $vokread[0][0]+1, $put & "/" & $put2)
EndIf
EndFunc
Func _update()
$tok = IniReadSection("Vok.ini","Vok")
If not @error Then
$z =Random(2,$tok[0][0],1)
MsgBox("","1",$z)
$tak = IniRead("Vok.ini","Vok","Vok" & $z,"")
MsgBox("","2",$tak)
$tstring = StringSplit($tak,"/")
_ArrayDisplay($tstring)
$z2 = Random(1,2,1)
If $z2 = 1 Then
$temparray[0] = 1
ElseIf $z2 = 2 Then
$temparray[0] = 2
EndIf
GUICtrlSetData($Label1,$tstring[$z2])
EndIf
EndFunc
Func _check()
$r3 = GUICtrlRead($Input1)
$zt = FileExists("Vok.ini")
If NOT $zt = True Then
MsgBox(0,".ini nicht gefunden","Vok.ini konnte nicht gefunden werden")
Else
If $r3 = "" Then
_update()
Else
If $temparray[0] <> 1 Then
If $r3 = $tstring[1] Then
GUICtrlSetData($Label1,"Richtig!")
Sleep(500)
_update()
Else
GUICtrlSetData($Label1,"Falsch!")
Sleep(500)
_update()
EndIf
ElseIf $temparray[0] <> 2 Then
If $r3 = $tstring[2] Then
GUICtrlSetData($Label1,"Richtig!")
Sleep(500)
_update()
Else
GUICtrlSetData($Label1,"Falsch!")
Sleep(500)
_update()
EndIf
EndIf
EndIf
EndIf
EndFunc
Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
GUICtrlSetData($Label1,$tstring[$z2])
GUICtrlSetData($Label1,^ ERROR
Wenn nur Vok und Vok2 drinne stehen -> Crash... Vok is nur als Platzhalter gedacht, damit es über IniReadSection keine Probleme bekommt...
EDIT:
Also ich hab mal n paar Änderungen vorgenommen, allerdings stellt sich mir immernoch das Problem mit der .ini...
Code:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Vokabeltrainer 0.1", 297, 130, 532, 287)
$Label1 = GUICtrlCreateLabel("", 56, 16,100,20)
$Input1 = GUICtrlCreateInput("", 16, 56, 121, 21)
$Button1 = GUICtrlCreateButton("OK", 16, 88, 121, 25)
$Button2 = GUICtrlCreateButton("Liste anzeigen", 152, 14, 121, 25)
$Button3 = GUICtrlCreateButton("Neue Vokabel", 152, 54, 121, 25)
$Button4 = GUICtrlCreateButton("Sprache", 152, 88, 121, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $temparray[1]
Global $tstring
;_update()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_check()
Case $Button2
;_list()
Case $Button3
_new()
Case $Button4
;_lang()
EndSwitch
WEnd
Func _new()
$put = InputBox("Vokabel","Bitte die Vokabel in Deutsch eingeben")
$put2 = InputBox("Vokabel","Übersetzung")
$vokread = IniReadSection("Vok.ini","Vok")
If @error Then
MsgBox(0,"Neue .ini", "Es wird eine neue Vok.ini erstellt, bitte Neueingabe wiederholen")
IniWrite("Vok.ini","Vok","Vok","Dump/Dump")
Else
IniWrite("Vok.ini","Vok","Vok" & $vokread[0][0]+1, $put & "/" & $put2)
EndIf
EndFunc
Func _update()
$tok = IniReadSection("Vok.ini","Vok")
If not @error Then
$z =Random(2,$tok[0][0],1)
MsgBox("","1",$z)
$tak = IniRead("Vok.ini","Vok","Vok" & $z,"")
MsgBox("","2",$tak)
$tstring = StringSplit($tak,"/")
_ArrayDisplay($tstring)
$z2 = Random(1,2,1)
If $z2 = 1 Then
$temparray[0] = 1
ElseIf $z2 = 2 Then
$temparray[0] = 2
EndIf
GUICtrlSetData($Label1,$tstring[$z2])
EndIf
EndFunc
Func _check()
$r3 = GUICtrlRead($Input1)
$zt = FileExists("Vok.ini")
If NOT $zt = True Then
MsgBox(0,".ini nicht gefunden","Vok.ini konnte nicht gefunden werden")
Else
If $r3 = "" Then
_update()
Else
If $temparray[0] <> 1 Then
If $r3 = $tstring[1] Then
GUICtrlSetData($Label1,"Richtig!")
Sleep(500)
_update()
Else
GUICtrlSetData($Label1,"Falsch!")
Sleep(500)
_update()
EndIf
ElseIf $temparray[0] <> 2 Then
If $r3 = $tstring[2] Then
GUICtrlSetData($Label1,"Richtig!")
Sleep(500)
_update()
Else
GUICtrlSetData($Label1,"Falsch!")
Sleep(500)
_update()
EndIf
EndIf
EndIf
EndIf
EndFunc
Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
GUICtrlSetData($Label1,$tstring[$z2])
GUICtrlSetData($Label1,^ ERROR
MsgBoxen bringen mir da nicht viel, da ich ja weiß, dass die Arrays nicht richtig geschrieben werden.
Nur fällt mir dazu im Moment keine richtige Lösung ein...