Jump to content

Folder Create


Recommended Posts

I'm trying to create a folder that will be read from an ini file and changeable from an input box. This is what I have, it will write to the ini, but it wont create the folder. Help please.

#include <GUIConstants.au3>
$Where='AutoMix.ini'

$Main = GUICreate ("Test folder", 283, 580);width, height


$label1 = GUICtrlCreateLabel ( "Create Folder.", 15,  200, 215, 20)
GUICtrlSetBkColor(-1,0xADC8DD)

$test1=IniRead($Where, 'tester', 'test', 'no')
$test2=GUICtrlCreateInput($test1, 15, 220, 215, 20)
iniwrite($Where, 'KeyBindings', 'KeyBindingsSend12', guictrlread($test2))

$ok = GUICtrlCreateButton("Ok", 10, 310, 80, 20)                            ;Submit button
GUICtrlSetBkColor(-1, 0xADC8DD)

$cancel = GUICtrlCreateButton("Cancel", 100, 310, 80, 20)                           ;Submit button
GUICtrlSetBkColor(-1, 0xADC8DD)
;DirCreate("C:\Test1\Folder1\Folder2")

GuiSetState()

While 1
    
        $msg = GUIGetMsg()
    Select  
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $cancel
            Exit    
        Case $msg = $ok 
            Function ()
    EndSelect
    
WEnd

Func Function ()
    
    iniwrite($Where, 'tester', 'test', guictrlread($test2))
    Sleep (5000)
    DirCreate ($test2)
EndFunc
Link to comment
Share on other sites

I'm trying to create a folder that will be read from an ini file and changeable from an input box. This is what I have, it will write to the ini, but it wont create the folder. Help please.

Would you show us what's in your ini file?
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

where it says dircreate($test2) in your funciton, do a guictrlread instead not just the variable name

by the way jefhal u dont really need to see whats in the INI cuz the prog does all the writing, so you just had to run it and it would tell you but it wasnt a big asset to solving the problem :), hell you didnt even have to run it all it was doing was writng what was in the input :(

o yeah and champak check in the scripts and scraps for colored buttons, you cant set the background color of a button with GUICtrlSetBkColor

Edited by thatsgreat2345
Link to comment
Share on other sites

  • Moderators

#include <GUIConstants.au3>
Local $Where = @ScriptDir & '\AutoMix.ini'

$Main = GUICreate("Test folder", 283, 580);width, height
$label1 = GUICtrlCreateLabel( "Create Folder.", 15,  200, 215, 20)
GUICtrlSetBkColor(-1,0xADC8DD)
$test1 = IniRead($Where, 'tester', 'test', 'no')
$test2 = GUICtrlCreateInput($test1, 15, 220, 215, 20)
IniWrite($Where, 'KeyBindings', 'KeyBindingsSend12', GUICtrlRead($test2))
$ok = GUICtrlCreateButton("Ok", 10, 310, 80, 20)                              ;Submit button
$cancel = GUICtrlCreateButton("Cancel", 100, 310, 80, 20)                             ;Submit button
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $cancel
            Exit
        Case $msg = $ok
            _Function($Where, GUICtrlRead($test2))
    EndSelect
WEnd

Func _Function($hLocation, $vKey)
    IniWrite($hLocation, 'tester', 'test', $vKey)
    Sleep(5000)
    DirCreate(@ScriptDir & '\' & $vKey)
EndFunc

I see thatsgreat2345 basically answered your question too now.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

thatsgreat2345, thanks, works great.

SmOke_N, could you explain what exactly is happening with what you are doing in that script so I can understand? It seems like extra unnecessary code.....seeing how the other works fine. Is there some type of security measure in what you are doing?

Link to comment
Share on other sites

  • Moderators

You are passing non global variables to a function your way, I simply corrected the issue. So it's not "unnecessary" as much as it is good coding habbits.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Are you saying every time I use a variable throughout the script I need to put "Local" just before it? Could you also point me to somewhere I can get more and precise info on this? I looked up the help but really didn't get anything from it, and I know if I do a search for "local" and "global" some 500 pages are going to come back.

Link to comment
Share on other sites

  • Moderators

Hmm, A "Global" or "Dim" variable is declared when you plan on using that variable throughout your script on a consistant basis, an example of it being used would be the HotKeySet() / TogglePause() function where it uses $Paused as a Global Variable and is able to be used in multiple functions with the "same" value.

A "Local" variable means that you plan on using that Variable in the scope of the local region or function. "Most" functions use this "Local" variable, because the are performing a "specific" task. Now the beauty of functions is that you don't have to only use them one way, this is why we set it up with parameters as I showed, because if you wish "That" function to do something else with another "key" or another "file" with the same section name, that you can have the freedom of changing those 2 options only without having to re-write the entire function to suit that one Function Call. Parameters are considered to be a "Local" variable, and shouldn't/can't be used as Global.

Since Valik stated a while back that "Dim" was basically an unnecessary option, I have tried to train myself to only use Local and Global vars.

Edit:

I should state for the record that this is my interpretation, if someone wishes to "correct" or "add to" what I've said feel free.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

OK, I understand....75% worth at least :"> , but I tried your version, and it does not work. It writes to the ini fine, but it is not creating the folder.

I tested it before I posted, exactly how it have it there and it did both (write to the ini and folder, but you probably changed @ScriptDir lol)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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