Das Ami Posted November 8, 2007 Share Posted November 8, 2007 (edited) I made a simple program that saves my notes in an ini file. When I use linefeeds (enter) in the editfield and save my note, then I can't load it from the ini anymore because iniread f&*ks up on the linefeeds. Is there a way to filter out the linefeeds with a replacement string/char and load them again? expandcollapse popupIf Not FileExists(@SystemDir&"\activenotes.ini") Then IniWrite(@SystemDir&"\activenotes.ini", "Notes", "1", "There was no ini file found on your computer, a new one has been created. (This seems to be your first time using activenotes)") EndIf $i=1 #include <GUIConstants.au3> $Form1 = GUICreate("Notes", 474, 467, 213, 221) $Edit1 = GUICtrlCreateEdit("", 0, 0, 473, 385, BitOR($ES_AUTOVSCROLL,$ES_WANTRETURN,$WS_VSCROLL)) $Button1 = GUICtrlCreateButton("Save", 1, 388, 233, 25, 0) $Button2 = GUICtrlCreateButton("New Note", 239, 388, 233, 25, 0) $Button3 = GUICtrlCreateButton("Reset", 1, 416, 233, 25, 0) $Button4 = GUICtrlCreateButton("Delete Note", 239, 416, 233, 25, 0) $Combo1 = GUICtrlCreateCombo("", 0, 443, 473, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "Jump to note", "Jump to note") GUISetState(@SW_SHOW) refresh() Func refresh() $var=IniReadSectionNames(@SystemDir&"\activenotes.ini") $r="" For $i = 1 To $var[0] $r=$r&"|"&$var[$i] Next GUICtrlSetData($Combo1,$r,$var[1]) GUICtrlSetData($Edit1,IniRead(@SystemDir&"\activenotes.ini",GUICtrlRead($Combo1),1,"Critical Error")) EndFunc While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Combo1 GUICtrlSetData($Edit1,IniRead(@SystemDir&"\activenotes.ini",GUICtrlRead($Combo1),1,"Critical Error")) Case $Button3 GUICtrlSetData($Edit1,"") Case $Button1 IniWrite(@SystemDir&"\activenotes.ini", GUICtrlRead($Combo1), "1", GUICtrlRead($Edit1)) Case $Button2 IniWrite(@SystemDir&"\activenotes.ini", InputBox("Name?"," "), "1", "") refresh() Case $Button4 If MsgBox(4,"Delete", "You sure?") = 6 Then IniDelete(@SystemDir&"\activenotes.ini", GUICtrlRead($Combo1)) refresh() EndIf EndSwitch WEnd Edited November 8, 2007 by Das Ami Link to comment Share on other sites More sharing options...
Developers Jos Posted November 8, 2007 Developers Share Posted November 8, 2007 just replace all Linefeeds with "\r" before saving it to the INI and reverse the process when reading... 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...
Das Ami Posted November 8, 2007 Author Share Posted November 8, 2007 Do you mean this? StringReplace(GUICtrlRead($Combo1),@LF,"\r") You use \r as a random replacement right? Because I think I might type that by accident. Link to comment Share on other sites More sharing options...
Developers Jos Posted November 8, 2007 Developers Share Posted November 8, 2007 Do you mean this? StringReplace(GUICtrlRead($Combo1),@LF,"\r") You use \r as a random replacement right? Because I think I might type that by accident.I used \r because thats often used but you could use anything "unique" like QX (dont believe that combination is used in any word but you never know ) 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...
Das Ami Posted November 8, 2007 Author Share Posted November 8, 2007 I used \r because thats often used but you could use anything "unique" like QX (dont believe that combination is used in any word but you never know )I see, thanks. 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