derkaderka Posted October 16, 2010 Share Posted October 16, 2010 Hello, I am trying to make a data compiler program using GUI. I was wondering if there is any way to save the data that is inputed to a local file. This would allow the data saved to be re opened and added to after the program is closed and re-opened. Is this possible? Link to comment Share on other sites More sharing options...
JohnOne Posted October 17, 2010 Share Posted October 17, 2010 There are a number of ways, .ini file .txt file, database files etc... the list goes on. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
derkaderka Posted October 17, 2010 Author Share Posted October 17, 2010 There are a number of ways, .ini file .txt file, database files etc... the list goes on.Yes but how would I save them without having the user open up notepad, copy and paste the data, and save? Link to comment Share on other sites More sharing options...
MrPPP Posted October 17, 2010 Share Posted October 17, 2010 Search in autoIt Help for: "IniWrite" There is everything you need;) Link to comment Share on other sites More sharing options...
derkaderka Posted October 17, 2010 Author Share Posted October 17, 2010 Search in autoIt Help for: "IniWrite" There is everything you need;) I figured out how to write the files, but it only reads what you put in quotations, how can get it to write a variable, and then read it after the program has been closed? Here is an example of what I mean: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("", 256, 101, 192, 124) $Input1 = GUICtrlCreateInput("", 35, 15, 193, 21) $Button1 = GUICtrlCreateButton("Write", 32, 56, 75, 25) $Button2 = GUICtrlCreateButton("Read", 136, 56, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 button1() Case $Button2 button2() EndSwitch WEnd Func button1() $READ1 = GUICtrlRead($Input1) Dim $CSVFILE = @ScriptDir & "C:\test.ini" $INIWRITE = IniWrite($CSVFILE, "Section 1", "key", $READ1) MsgBox(0, "Done", "INI Write Complete") EndFunc Func button2() Dim $CSVFILE = @ScriptDir & "C:\test.ini" $INIREAD = IniRead($CSVFILE, "Section 1", "key", "Example") $DIZINAYAR = GUICtrlSetData($Input1, $INIREAD) EndFunc Is there a way that I can get it to write whatever is in the input section, then read it after the program has been re opened? I am trying to save user profiles in a program. Link to comment Share on other sites More sharing options...
Bowmore Posted October 17, 2010 Share Posted October 17, 2010 Below is a simple example, to get you started, of saving the contents of the controls on a GUI on exit and restoring them when the application is restarted. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $sData1 = "" Global $sData2 = "" _ReadSettings() $Form1 = GUICreate("", 256, 101, 192, 124) $Input1 = GUICtrlCreateInput($sData1, 35, 15, 193, 21) $Input2 = GUICtrlCreateInput($sData2, 35, 45, 193, 21) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _SaveSettings() Exit EndSwitch WEnd Func _ReadSettings() $sData1 = IniRead(@ScriptDir & "\test.ini","SETTINGS","input1","") $sData2 = IniRead(@ScriptDir & "\test.ini","SETTINGS","input2","") EndFunc Func _SaveSettings() $sData1 = IniWrite(@ScriptDir & "\test.ini","SETTINGS","input1",GUICtrlRead($Input1)) $sData2 = IniWrite(@ScriptDir & "\test.ini","SETTINGS","input2",GUICtrlRead($Input2)) EndFunc "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
derkaderka Posted October 19, 2010 Author Share Posted October 19, 2010 Bowmore, this was exactly what I was looking for, 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