Jump to content
Sign in to follow this  
JohnOne

IniWrite

Recommended Posts

JohnOne

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
Valuater

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
JohnOne

Brilliant >_<

I appreciate your time mate

That should give me enough to be getting on with

Also I was able to remove the line $sIni =

@DesktopDir & "\name.ini"
Edited by JohnOne

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

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.