AustrianOak Posted June 11, 2008 Share Posted June 11, 2008 (edited) im writing to an ini in a function and it's in a for loop. at first i though it was the for loop causing data to be lost then i figured out it was the way i was writing to my .ini file. (then again it could be the for loop, i need some serious help ) here is what my ini looks like before written to: [section1] Key1=value1;value2 here's how i am writing to my ini: IniWrite(@ScriptDir & "\temp.ini", "section1", "Key1", IniRead(@ScriptDir & "\temp.ini", "section1", $name, "") & $name & "|" & _NowDate()) it is "supposed" to take value1 and value2 and input them in an external app (it does this fine) then i want each of them to be written back into the ini file with the date next to each. so it would look like this: [section1] Key1=value1|date;value2|date this is what my for loop looks like: For $a = 0 To $count - 1 $var = _GUICtrlListBox_GetText($externapp, $a); Gets the tables/items If $var = -1 Then $var = "No" Else EndIf $getcount = _GUICtrlListBox_GetCount($externapp) If $getcount > 0 Then IniWrite(@ScriptDir & "\temp.ini", "section1", "Key1", IniRead(@ScriptDir & "\temp.ini", "section1", $name, "") & $name & "|" & _NowDate()) _GUICtrlListView_SetItemText($ListView, $a, $var) $date = GUICtrlSetData($Img, "||" & _NowDate()) Else EndIf Next i dont know if showing you the for loop will make a difference but its either that or the way im writing to the ini that keeps screwing my ini file up. im pretty sure its the way i write to the ini... help? Edited June 11, 2008 by nowagain Link to comment Share on other sites More sharing options...
cartman380 Posted June 11, 2008 Share Posted June 11, 2008 I've found that in-line retrieving of data doesn't work reliably (or at all for the time I tried it). you could try this: $temp = IniRead(@ScriptDir & "\temp.ini", "section1", $name, "") IniWrite(@ScriptDir & "\temp.ini", "section1", "Key1", $temp & $name & "|" & _NowDate()) Link to comment Share on other sites More sharing options...
AustrianOak Posted June 11, 2008 Author Share Posted June 11, 2008 (edited) i tried the code and it still doesnt write to it properly the ini looks like this now: [section1] Key1=value1;value2value1|6/11/2008value1|6/11/2008value2|6/11/2008 Edit: Would it be the position the iniwrite() is in in the for loop? just a thought that the data could be overwritten in the loop Edited June 11, 2008 by nowagain Link to comment Share on other sites More sharing options...
martin Posted June 11, 2008 Share Posted June 11, 2008 i tried the code and it still doesnt write to it properly the ini looks like this now: [section1] Key1=value1;value2value1|6/11/2008value1|6/11/2008value2|6/11/2008 Edit: Would it be the position the iniwrite() is in in the for loop? just a thought that the data could be overwritten in the loopMaybe this will do it, but not tested. $ddate = _NowDate();no need to keep calculating the same thing For $a = 0 To $count - 1 $var = _GUICtrlListBox_GetText ($externapp, $a); Gets the tables/items If $var = -1 Then $var = "No" Else EndIf $getcount = _GUICtrlListBox_GetCount ($externapp) If $getcount > 0 Then $keydat = IniRead(@ScriptDir & "\temp.ini", "section1", $name, "") If $keydat <> "" Then $keydat = StringReplace($keydat, ";", "|" & $ddate & ";") & "|" & $ddate IniWrite(@ScriptDir & "\temp.ini", "section1", "Key1", $keydat) EndIf _GUICtrlListView_SetItemText ($ListView, $a, $var) $date = GUICtrlSetData($Img, "||" & $ddate) Else EndIf Next Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
AustrianOak Posted June 11, 2008 Author Share Posted June 11, 2008 (edited) ok this is the closest its ever been but not quite finished the ini looks like this now: [section1] Key1=value1|6/11/2008|6/11/2008|6/11/2008|6/11/2008|6/11/2008|6/11/2008;value2| 6/11/2008|6/11/2008|6/11/2008|6/11/2008|6/11/2008|6/11/2008 the only problem is instead of putting the date once like its supposed to it puts it 6 times for both buddies... Edited June 11, 2008 by nowagain Link to comment Share on other sites More sharing options...
AustrianOak Posted June 11, 2008 Author Share Posted June 11, 2008 (edited) $keydat = StringReplace($keydat, ";", "|" & $ddate & ";") & "|" & $ddatemaybe this is part of the problem, the bolded section i cannot see why it is needed at all?it seems like all that was needed to be done was in the stringreplace() and i dont see why the bolded is needed.please correct me if im wrong. Edited June 11, 2008 by nowagain Link to comment Share on other sites More sharing options...
martin Posted June 11, 2008 Share Posted June 11, 2008 $keydat = StringReplace($keydat, ";", "|" & $ddate & ";") & "|" & $ddate maybe this is part of the problem, the bolded section i cannot see why it is needed at all? it seems like all that was needed to be done was in the stringreplace() and i dont see why the bolded is needed. please correct me if im wrong.The bold part is there because, as I understood your first post, you asked for it to be there. [section1] Key1=value1;value2 here's how i am writing to my ini: CODE IniWrite(@ScriptDir & "\temp.ini", "section1", "Key1", IniRead(@ScriptDir & "\temp.ini", "section1", $name, "") & $name & "|" & _NowDate()) it is "supposed" to take value1 and value2 and input them in an external app (it does this fine) then i want each of them to be written back into the ini file with the date next to each. so it would look like this: [section1] Key1=value1|date;value2|date Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
AustrianOak Posted June 11, 2008 Author Share Posted June 11, 2008 i solved the rest of this problem, it had to do with the positioning of the iniwrite() in the for loop. thanks! Link to comment Share on other sites More sharing options...
AustrianOak Posted June 12, 2008 Author Share Posted June 12, 2008 @martin: your method i implemented into my program works fine the first time. but somehow it increments the date in the ini the second time so there is two dates and then everything messes up from there. here's what it looks like: value1|6/12/2008|6/12/2008;value2|6/12/2008|6/12/2008 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