Jump to content

IniWrite


Recommended Posts

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.

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

Link to comment
Share on other sites

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.

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...