|
You last visited: Today at 00:27
Advertisement
Arraywerte
Discussion on Arraywerte within the AutoIt forum part of the Coders Den category.
08/27/2010, 20:47
|
#1
|
elite*gold: 0
Join Date: Jul 2009
Posts: 2,241
Received Thanks: 848
|
Arraywerte
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[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...
|
|
|
08/28/2010, 13:05
|
#2
|
elite*gold: 0
Join Date: Jun 2010
Posts: 171
Received Thanks: 52
|
den script jeck ich zwar ned so ganz aber nimm doch einfach:
Global $tstring her das müsste eigentlich klappen
|
|
|
08/28/2010, 21:23
|
#3
|
elite*gold: 2
Join Date: Mar 2008
Posts: 1,778
Received Thanks: 1,222
|
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
|
|
|
08/28/2010, 22:08
|
#4
|
elite*gold: 0
Join Date: Apr 2008
Posts: 1,079
Received Thanks: 438
|
Quote:
Originally Posted by mipez
...ich will die Werte aus $tstring für das ganze Script speichern...
|
Häh, wie du meinen?...
|
|
|
08/29/2010, 10:11
|
#5
|
elite*gold: 0
Join Date: Jul 2009
Posts: 2,241
Received Thanks: 848
|
Quote:
Originally Posted by | Moep |
Häh, wie du meinen?...
|
$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ô
|
|
|
08/29/2010, 12:03
|
#6
|
elite*gold: 0
Join Date: Apr 2008
Posts: 1,079
Received Thanks: 438
|
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
|
|
|
08/29/2010, 12:10
|
#7
|
elite*gold: 0
Join Date: Jul 2009
Posts: 2,241
Received Thanks: 848
|
Quote:
Originally Posted by | Moep |
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
|
|
|
08/29/2010, 12:36
|
#8
|
elite*gold: 0
Join Date: Apr 2008
Posts: 1,079
Received Thanks: 438
|
Quote:
Originally Posted by mipez
_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
|
Also in der version die du als letzes gepostet hast funzt update nicht, somit kann ich auch den rest nicht testen.
|
|
|
08/29/2010, 12:39
|
#9
|
elite*gold: 0
Join Date: Jul 2009
Posts: 2,241
Received Thanks: 848
|
Quote:
Originally Posted by | Moep |
Also in der version die du als letzes gepostet hast funzt update nicht, somit kann ich auch den rest nicht testen.
|
Hm, funzt nur wenn Vok.ini bereits vorhanden is... wenn ich die bei Scriptstart rausnehme und bei _check als Start einbaue müsste es klappen...
Hm wenn die .ini min 3 Einträge hat klappt es, sonst gibts'n Crash oô
Code:
[Vok]
Vok=Dump/Dump
Vok2=Hallo/hello
Vok3=Blubb/Blubb
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
Code:
[Vok]
Vok=Dump/Dump
Vok2=Hallo/hello
Wie gesagt, ab Vok3 funktioniert es...
|
|
|
08/29/2010, 18:17
|
#10
|
elite*gold: 0
Join Date: Apr 2008
Posts: 1,079
Received Thanks: 438
|
Quote:
Originally Posted by mipez
Hm, funzt nur wenn Vok.ini bereits vorhanden is... wenn ich die bei Scriptstart rausnehme und bei _check als Start einbaue müsste es klappen...
Hm wenn die .ini min 3 Einträge hat klappt es, sonst gibts'n Crash oô
Code:
[Vok]
Vok=Dump/Dump
Vok2=Hallo/hello
Vok3=Blubb/Blubb
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
Code:
[Vok]
Vok=Dump/Dump
Vok2=Hallo/hello
Wie gesagt, ab Vok3 funktioniert es...
|
look at post 6!...
|
|
|
08/29/2010, 20:43
|
#11
|
elite*gold: 0
Join Date: Jul 2009
Posts: 2,241
Received Thanks: 848
|
Quote:
Originally Posted by | Moep |
look at post 6!...
|
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...
|
|
|
All times are GMT +1. The time now is 00:28.
|
|