Jump to content

Help-Data Save Scrip


Recommended Posts

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...