Sam1el Posted August 1, 2011 Share Posted August 1, 2011 I"m not gonna lie. I'm completely new. I may be getting in way over my head but I wanted to ask if what i'm doing is even possible. I created a script recently that would read arrays from 2 .csv files and use that info to create a structure of folders with sub folders predetermined. I have been reading the helpfile on gui creation and I have written some of the examples with my own twists multiple times just to understand how they work. What I want the gui to do is allow them to choose their own csv files and then create the directories. I know I will need 2 buttons that will open tree view to select the .csv files they want. I'm just not really sure how to make _filereadtoarray and dircreate integrate with the gui functions. I by no means want anyone to do this for me but maybe a push in the right direction or some examples would be greatly appreciated. Here is the working script i will be using. #include <File.au3> ;needed for _FileReadToArray function Dim $asDirList ;declare array var for lines of file Dim $asDirList2 _FileReadToArray("dir.csv", $asDirList);read lines of file into array with 1st element=num of lines read _FileReadToArray("subs.csv", $asDirList2) If @error Then MsgBox(0, "", "Error, Could not read file.") For $i = 1 To $asDirList[0] For $2 = 1 To $asDirList2[0] $asDirList[$i] = StringRegExpReplace($asDirList[$i], ",(\w+)", " $1") ;replace ,test with _test $asDirList[$i] = StringReplace($asDirList[$i], ",", "") ;remove trailing commas DirCreate(@ScriptDir & "\" & $asDirList[$i] & "\" & $asDirList2[$2]) ;create dir Next Next Link to comment Share on other sites More sharing options...
Zedna Posted August 1, 2011 Share Posted August 1, 2011 Maybe this: #include <File.au3> ;needed for _FileReadToArray function Dim $asDirList ;declare array var for lines of file Dim $asDirList2 $csv1 = FileOpenDialog('Select CSV file 1', @ScriptDir & "\", "CSV (*.csv)", 1 + 2 ) If @error Then MsgBox(4096,"","No File 1 chosen") Exit EndIf $csv2 = FileOpenDialog('Select CSV file 2', @ScriptDir & "\", "CSV (*.csv)", 1 + 2 ) If @error Then MsgBox(4096,"","No File 2 chosen") Exit EndIf _FileReadToArray($csv1, $asDirList);read lines of file into array with 1st element=num of lines read If @error Then MsgBox(0, "", "Error, Could not read file 1.") _FileReadToArray($csv2, $asDirList2) If @error Then MsgBox(0, "", "Error, Could not read file 2.") For $i = 1 To $asDirList[0] For $2 = 1 To $asDirList2[0] $asDirList[$i] = StringRegExpReplace($asDirList[$i], ",(\w+)", " $1") ;replace ,test with _test $asDirList[$i] = StringReplace($asDirList[$i], ",", "") ;remove trailing commas DirCreate(@ScriptDir & "\" & $asDirList[$i] & "\" & $asDirList2[$2]) ;create dir Next Next Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Sam1el Posted August 1, 2011 Author Share Posted August 1, 2011 Maybe this: #include <File.au3> ;needed for _FileReadToArray function Dim $asDirList ;declare array var for lines of file Dim $asDirList2 $csv1 = FileOpenDialog('Select CSV file 1', @ScriptDir & "\", "CSV (*.csv)", 1 + 2 ) If @error Then MsgBox(4096,"","No File 1 chosen") Exit EndIf $csv2 = FileOpenDialog('Select CSV file 2', @ScriptDir & "\", "CSV (*.csv)", 1 + 2 ) If @error Then MsgBox(4096,"","No File 2 chosen") Exit EndIf _FileReadToArray($csv1, $asDirList);read lines of file into array with 1st element=num of lines read If @error Then MsgBox(0, "", "Error, Could not read file 1.") _FileReadToArray($csv2, $asDirList2) If @error Then MsgBox(0, "", "Error, Could not read file 2.") For $i = 1 To $asDirList[0] For $2 = 1 To $asDirList2[0] $asDirList[$i] = StringRegExpReplace($asDirList[$i], ",(\w+)", " $1") ;replace ,test with _test $asDirList[$i] = StringReplace($asDirList[$i], ",", "") ;remove trailing commas DirCreate(@ScriptDir & "\" & $asDirList[$i] & "\" & $asDirList2[$2]) ;create dir Next Next Something like that would work. I was thinking more of an interface with some browse type buttons but, that's more than I was able to make it do and your code shows me some of what I was overthinking thank you very much Link to comment Share on other sites More sharing options...
Zedna Posted August 2, 2011 Share Posted August 2, 2011 For GUI definitely look at Koda I can help you integrate it to your GUI Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Sam1el Posted August 2, 2011 Author Share Posted August 2, 2011 For GUI definitely look at KodaI can help you integrate it to your GUII been reading up on it all day. been messing with it for an hour or so. I'm managed to create my buttons and get the interface how I like. i'm strugling with the onclick functions at the moment. Link to comment Share on other sites More sharing options...
sleepydvdr Posted August 3, 2011 Share Posted August 3, 2011 I been reading up on it all day. been messing with it for an hour or so. I'm managed to create my buttons and get the interface how I like. i'm strugling with the onclick functions at the moment. I have never understood the onclick part of Koda. You just gave me the motivation to look at it again. It seems that enabling that option mere creates the "Case $Button1" section for you (or whatever gui control you enabled it for). If it is set to not notify, it doesn't create that line for you. I always just typed up that part myself. Here's part of the while loop that reacts to you clicking a button: While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ; this is what should happen when you click the button. Example on next line: call a function _MyMsgBox() EndSwitch WEnd Func _MyMsgBox() MsgBox(0, "", "You clicked the button") EndFunc #include <ByteMe.au3> Link to comment Share on other sites More sharing options...
Zedna Posted August 3, 2011 Share Posted August 3, 2011 I been reading up on it all day. been messing with it for an hour or so. I'm managed to create my buttons and get the interface how I like. i'm strugling with the onclick functions at the moment.Koda is tool for creating only GUI part of your script, not the rest of code.In Koda just create GUI with desired controls and then generate AU3 code.Then manually modify this AU3 code by adding whole logic. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Sam1el Posted August 3, 2011 Author Share Posted August 3, 2011 Koda is tool for creating only GUI part of your script, not the rest of code.In Koda just create GUI with desired controls and then generate AU3 code.Then manually modify this AU3 code by adding whole logic. ahh ok.THen i guess the part in koda I need help withis a browse button with a text box next to it that shows the file you chose that's what i've been fighting with Link to comment Share on other sites More sharing options...
Zedna Posted August 3, 2011 Share Posted August 3, 2011 Create your GUI, generate AU3 and post your code here... Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now