Sign in to follow this  
Followers 0
Bliz0r

Filecreate with a input variable as name.

2 posts in this topic

Hello, I made this pierce of code to create a file containing different inputs. And as a name I made it use a another input variable.

#include <GUIConstants.au3>
#include <File.au3>

Global $Profmng
Global $Save
Global $Cancel
Global $Username
Global $Password
Global $Brw1
Global $Lng1
Global $Name2

$Profmng = GUICreate ("Profile Creation", 276, 179, 271, 226)
$User = GUICtrlCreateInput ("Username here", 0, 64, 121, 21)
$Pass = GUICtrlCreateInput ("", 128, 64, 121, 21, $ES_PASSWORD)
$Browser = GUICtrlCreateCombo ("Select", 0, 112, 121, 25)
GUICtrlSetData (-1, "Internet Explorer|Mozilla Firefox")
$Language = GUICtrlCreateCombo ("Select", 128, 112, 121, 25)
GUICtrlSetData (-1, "English|Danish")
$Save = GUICtrlCreateButton ("Save", 0, 144, 75, 25, 0)
$Cancel = GUICtrlCreateButton ("Cancel", 80, 144, 75, 25, 0)
$Username = GUICtrlCreateLabel ("Username", 0, 48, 52, 17)
$Password = GUICtrlCreateLabel ("Password", 128, 48, 50, 17)
$Brw1 = GUICtrlCreateLabel ("Browser", 0, 96, 42, 17)
$Lng1 = GUICtrlCreateLabel ("Language", 128, 96, 52, 17)
$Name2 = GUICtrlCreateLabel ("Name", 0, 0, 32, 17)
$Name = GUICtrlCreateInput ("Profile name here", 0, 16, 121, 21)

GUISetState (@SW_SHOW)


While 1
    $pMsg = GUIGetMsg ()
    Select
        Case $pMsg = $GUI_EVENT_CLOSE
            Exit
        Case $pMsg = $Cancel
            Exit
        Case $pMsg = $Save
            $hfile = _FileCreate ($Name & ".ini")
            
            FileOpen ($Name & ".ini", 1)
            If $hfile = -1 Then
                MsgBox (0, "Error", "Unable to open file.")
            EndIf
            
            $Us1 = GuiCtrlRead ($User)
            FileWriteLine ($hfile, $Us1)
            $Pa1 = GuiCtrlRead ($Pass)
            FileWriteLine ($hfile, $Pa1)

            FileWriteLine ($hfile, GuiCtrlRead ($Language))
            FileWriteLine ($hfile, GuiCtrlRead ($Browser))

            FileClose ($hfile)
            
            Exit
    EndSelect
WEnd

When I've inputted some values, the file just turns out to get named "14", doesnt matter whatever have been inputted in the $name variable. Why is that?

Share this post


Link to post
Share on other sites



$Name = 14 because it is the 14th thing created.... You are calling the ID of the control not the data.

You are looking for:

FileOpen (GUICtrlRead($Name) & ".ini", 1)

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