Erik. Posted March 16, 2007 Share Posted March 16, 2007 Hi, I am trying to add a message func to my script: Func BerichtM() $Gui = GUICreate("Bericht aan medewerkers",260,150,303,219) GUICtrlCreateLabel("Je naam:",5,5) GUICtrlCreateLabel("Bericht:",5,40) $naam = GUICtrlCreateInput("",50,5,75,20) $bericht = GUICtrlCreateInput("",50,40,200,75,$ES_MULTILINE) $opslaan = GUICtrlCreateButton("Opslaan",50,120,50,25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($Gui) Exitloop Case $opslaan If GUICtrlRead($naam) = "" or GUICtrlRead($bericht) = "" Then MsgBox(48,"Error","Vul alle velden in aub") Else Iniwrite($infobericht,"BerichtM",Iniread($infobericht,"TotaaltM","1","" +1),GUICtrlRead($naam) & "|" & GUICtrlRead($bericht)) $readaantal = Iniread($infobericht,"TotaalM","1","") IniWrite($infobericht,"TotaalM","1",$readaantal+1) MsgBox(0,"Success","Bericht is opgeslagen en wordt de volgende keer dat het programma geopend wordt getoond") GUICtrlSetData($naam,"") GUICtrlSetData($bericht,"") Endif EndSwitch WEnd Return EndFunc Now needs the program to read the section TotaalM and do + 1 so i can set more then one message The problem is when the program writes to the ini file he always write to section BerichtM key 1 and not the key that was read and +1 Could you help me please I little problem, hard to find and fix Link to comment Share on other sites More sharing options...
Developers Jos Posted March 16, 2007 Developers Share Posted March 16, 2007 +1 is at the wrong spot ? Iniwrite($infobericht,"BerichtM",Iniread($infobericht,"TotaaltM","1","")+1,GUICtrlRead($naam) & "|" & GUICtrlRead($bericht)) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Erik. Posted March 16, 2007 Author Share Posted March 16, 2007 (edited) Hi, No i have found it already.. Always when i post something then look to the script i have found it. I have one letter wrong:P Edited March 16, 2007 by Erik. I little problem, hard to find and fix Link to comment Share on other sites More sharing options...
Erik. Posted March 16, 2007 Author Share Posted March 16, 2007 Ok next:P $totaalM = Iniread($infobericht,"TotaalM","1","" -1) If $totaalM >0 Then For $si = 0 To Iniread($infobericht,"TotaalM","1","") $string3 = StringSplit(IniRead($infobericht,"BerichtM",$si,""),"|") MsgBox(0,"Bericht","Bericht van: " & $string3[1] & @CRLF & "Bericht:") Next EndIf Whit this you can read the database for messages.. Now does it work for 50% When i use $string3[2] i got a error And when i add 1 message and restart the program then it needs to display all messages there are but i always got one at the end whit nothing into it what could be my problem? I little problem, hard to find and fix Link to comment Share on other sites More sharing options...
Joon Posted March 16, 2007 Share Posted March 16, 2007 Ok next:P $totaalM = Iniread($infobericht,"TotaalM","1","" -1) If $totaalM >0 Then For $si = 0 To Iniread($infobericht,"TotaalM","1","") $string3 = StringSplit(IniRead($infobericht,"BerichtM",$si,""),"|") MsgBox(0,"Bericht","Bericht van: " & $string3[1] & @CRLF & "Bericht:") Next EndIf Whit this you can read the database for messages.. Now does it work for 50% When i use $string3[2] i got a error And when i add 1 message and restart the program then it needs to display all messages there are but i always got one at the end whit nothing into it what could be my problem? Check $string3[0] > 2 Link to comment Share on other sites More sharing options...
Erik. Posted March 16, 2007 Author Share Posted March 16, 2007 Hi, String 2 is ok, string 2 must me the message I got a perfect message whit the name and the mesaage but when i click at ok the program crash.. Got this error: ---- (236) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: MsgBox(0,"Bericht","Bericht van: " & $string3[1] & @CRLF & "Bericht:" & $string3[2]) MsgBox(0,"Bericht","Bericht van: " & $string3[1] & @CRLF & "Bericht:" & ^ ERROR And i got one mesaage to many whit nothing into it how can i fix that? I little problem, hard to find and fix Link to comment Share on other sites More sharing options...
Joon Posted March 16, 2007 Share Posted March 16, 2007 try $totaalM = Iniread($infobericht,"TotaalM","1","" -1) If $totaalM >0 Then For $si = 0 To Iniread($infobericht,"TotaalM","1","") $string3 = StringSplit(IniRead($infobericht,"BerichtM",$si,""),"|") If $string3[0] >= 2 Then MsgBox(0,"Bericht","Bericht van: " & $string3[1] & @CRLF & "Bericht:" & $string3[2]) Else MsgBox(0,"Bericht","Bericht van: " & $string3[1] & @CRLF & "Bericht:") EndIf Next EndIf Link to comment Share on other sites More sharing options...
Erik. Posted March 17, 2007 Author Share Posted March 17, 2007 Hi, The program does not crash anymore.. I can add allot of messages... The probelm is when i add 1 message i always got 2 messages one whit the good messages and the second is fake.. When i add 3 messages i get 4 popups... one is fake how to delete that one so you only got real messages? I little problem, hard to find and fix Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now