Sign in to follow this  
Followers 0
JohnOne

IniWrite

3 posts in this topic

Is it possible to give the ini file you create a name based on a variable while creating the file (if you get me

I've been experimenting on one of the examples from the AutoIt help file, bu a bit stumped

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 214, 92, 192, 124)
$Input1 = GUICtrlCreateInput("Input1", 8, 16, 161, 21)
$Button1 = GUICtrlCreateButton("Cancel", 24, 48, 75, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Create", 120, 48, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Exit
        Case $Button2
            $sIni = @DesktopDir & "\name.ini"
            $data = GUICtrlRead($Input1)
            IniWrite($sIni, "section2", "key", "this is a new value")
            Exit
    EndSwitch
WEnd

I would like to name the ini file which this code creates by the value of $Input1

So when the script is ran, the resulting file in this case would be Input1.ini

Once again I apologise if my question is noob


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites



Maybe....

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 214, 92, 192, 124)
$Input1 = GUICtrlCreateInput("Input1", 8, 16, 161, 21)
$Button1 = GUICtrlCreateButton("Cancel", 24, 48, 75, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Create", 120, 48, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Exit
        Case $Button2
            $sIni = @DesktopDir & "\name.ini"
            $data = GUICtrlRead($Input1)
            IniWrite(@DesktopDir & "\" & $data & ".ini", "section2", "key", "this is a new value")
            Exit
    EndSwitch
WEnd

BTW, I appreciate the example script!!!

8)


NEWHeader1.png

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
Sign in to follow this  
Followers 0