Neeeewbie

IniWrite, What I'm I doing wrong?

5 posts in this topic

#1 ·  Posted

I'm trying to make a super basic GUI where I can type in a Name (lets say User123) and some text (like has my in game super spiffy sword) and click update <- where it would create a ini that I can load latter and edit/update as needed.

:blink: I'm having issues with it creating the ini.

 

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
;GUI start
$Form1 = GUICreate("Form1", 518, 330, 200, 121)
$Button1 = GUICtrlCreateButton("Search", 30, 264, 105, 41, $WS_GROUP)
;$Button2 = GUICtrlCreateButton("Edit", 140, 264, 105, 41, $WS_GROUP); idk why I made this button
$Button3 = GUICtrlCreateButton("Update", 250, 264, 105, 41, $WS_GROUP)
$Button4 = GUICtrlCreateButton("Exit", 375, 264, 105, 41, $WS_GROUP)
$Edit1 = GUICtrlCreateEdit("event log here", 40, 64, 429, 161)
GUICtrlSetData(-1, "Event log here")
$Input1 = GUICtrlCreateInput("UserNameHere", 72, 24, 129, 21)
$Username = GUICtrlCreateLabel("UserName", 16, 24, 52, 17)
GUISetState(@SW_SHOW)
;GUI end

While 1

Sleep(10)

  $msg = GUIGetMsg()
    Select

    Case $msg = $Button1
 ConsoleWrite ( "Search was pushed" )


;        Case $msg = $Button2
 ;ConsoleWrite ( "Edit was pushed" )


        Case $msg = $Button3
ConsoleWrite ( "Update was pushed" )
   $Input1 = $Input1
      IniWrite(@ScriptDir, $Input1, "History Log", $Edit1)
   ConsoleWrite ($Input1)
   ConsoleWrite ($Edit1)


     Case $msg = $Button4
 ConsoleWrite ( "Exit was pushed" )
Exit
    EndSelect

WEnd
Exit

 

^it doesn't seem to make the ini file.

Can someone point out my mistake? Probably something simple I'm just not seeing.

Share this post


Link to post
Share on other sites



#2 ·  Posted

From:

IniWrite(@ScriptDir, $Input1, "History Log", $Edit1)

To:

IniWrite(@ScriptDir & "\MyFile.ini", GUICtrlRead($Input1), "History Log", GUICtrlRead($Edit1))


________________________________________________________________________

IniWrite

Writes a value to a standard format .ini file.

IniWrite ( "filename", "section", "key", "value" )

Parameters

filename The filename of the .ini file.
section The section name in the .ini file.
key The key name in the .ini file.
value The value to write/change.

Return Value

Success: 1.
Failure: 0 if file is read-only.

Remarks

A standard ini file looks like:

[SectionName]
Key=Value

 

 

1 person likes this

Regards,
 

Share this post


Link to post
Share on other sites

#3 ·  Posted

:o dank you.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

New issue. It wrights and reads fine but when I click the edit text box (after searching/loading one) It like to erase/go back to the default "event log here".

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
;GUI start
$Form1 = GUICreate("Form1", 518, 330, 200, 121)
$Button1 = GUICtrlCreateButton("Search", 30, 264, 105, 41, $WS_GROUP)
;$Button2 = GUICtrlCreateButton("Edit", 140, 264, 105, 41, $WS_GROUP); idk why I made this button
$Button3 = GUICtrlCreateButton("Update", 250, 264, 105, 41, $WS_GROUP)
$Button4 = GUICtrlCreateButton("Exit", 375, 264, 105, 41, $WS_GROUP)
$Edit1 = GUICtrlCreateEdit("event log here", 40, 64, 429, 161)
GUICtrlSetData(-1, "Event log here")
$Input1 = GUICtrlCreateInput("UserNameHere", 72, 24, 129, 21)
$Username = GUICtrlCreateLabel("UserName", 16, 24, 52, 17)
GUISetState(@SW_SHOW)
;GUI end

While 1

Sleep(10)

  $msg = GUIGetMsg()
    Select

    Case $msg = $Button1
 ConsoleWrite ( "Search was pushed" )
$sRead = IniRead(@ScriptDir & "\MyFile.ini", GUICtrlRead($Input1), "History Log", GUICtrlRead($Edit1))
$Edit1 = GUICtrlCreateEdit($sRead, 40, 64, 429, 161)

;        Case $msg = $Button2
 ;ConsoleWrite ( "Edit was pushed" )


        Case $msg = $Button3
ConsoleWrite ( "Update was pushed" )
IniWrite(@ScriptDir & "\MyFile.ini", GUICtrlRead($Input1), "History Log", GUICtrlRead($Edit1))



     Case $msg = $Button4
 ConsoleWrite ( "Exit was pushed" )
Exit
    EndSelect

WEnd
Exit

 

Edited by Neeeewbie

Share this post


Link to post
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