melf Posted June 2, 2006 Share Posted June 2, 2006 (edited) Hi I searched on the forum but have been unable to find a way to generate a .txt file that has the name of all files in a folder line by line , example : file1.ini file2.ini file3.ini My code needs to load info from files in a specific folder but to do that i need a generate list so i have arguments to load them..something around the lines of : $file = FileOpen("generatedlist.txt", 0) $line = FileReadLine($file[1]) $var = IniRead($line, "NAME", "key", "") GUICtrlSetData($var, $showname) $line2 = FileReadLine($file[2]) $var2 = IniRead($line2, "NAME", "key", "") GUICtrlSetData($var2, $showname2) and so on and so forth..so that the 40 input boxes have the the Names inside each .ini file loaded in the boxes.. any help would be appreciated thx P.S i think there was a dos command script that generated lists but i havent been able to find it with the forum search option. Edited June 2, 2006 by melf Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 2, 2006 Moderators Share Posted June 2, 2006 Look at FileFindFirstFile()/FileFindNextFile() - Then Store them in an array or write them to the file you want, and sort as needed. 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 More sharing options...
melf Posted June 2, 2006 Author Share Posted June 2, 2006 (edited) hmmm and how could i set it so that each FileFindNextFile find has an automatic numbered $var? ( $var1, $var2$, etc) without having to script an entry for each? Edited June 2, 2006 by melf Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 2, 2006 Moderators Share Posted June 2, 2006 If that's the case then just look at the Beta _FileListToArray() option, nice and simple return. 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 More sharing options...
melf Posted June 2, 2006 Author Share Posted June 2, 2006 hmm k let me rephrase that i want to know how to set the FileFindNextFile find to a seperate attribute ( first file name found name becomes $var1 , second name become's $var2 , etc..) im having trouble's understanding the arrays Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 2, 2006 Moderators Share Posted June 2, 2006 hmm k let me rephrase thati want to know how to set the FileFindNextFile find to a seperate attribute( first file name found name becomes $var1 , second name become's $var2 , etc..)im having trouble's understanding the arraysThe function I gave you (_FileListToArray()) will do that. Just give it the File/Folder you want to search. 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 More sharing options...
melf Posted June 2, 2006 Author Share Posted June 2, 2006 Ah ok..i get it now..but lets say i want it to skip an empty array? i got 10 entry's but lets say i have only 6 files in the folder?..for the moment the script crashes on me because i have excedding arrays.. expandcollapse popup#Include <File.au3> #Include <Array.au3> #include <GuiConstants.au3> GuiCreate("MyGUI", 800, 600,-1, -1 ) GUICtrlCreateLabel("Number", 10, 32) $nombres = GUICtrlCreateInput("", 96, 32, 30, 20) $autobus = GUICtrlCreateInput("", 96, 52, 130, 20) $autobus1 = GUICtrlCreateInput("", 96, 72, 130, 20) $autobus2 = GUICtrlCreateInput("", 96, 92, 130, 20) $autobus3 = GUICtrlCreateInput("", 96, 112, 130, 20) $autobus4 = GUICtrlCreateInput("", 96, 132, 130, 20) $autobus5 = GUICtrlCreateInput("", 96, 152, 130, 20) $autobus6 = GUICtrlCreateInput("", 96, 172, 130, 20) $autobus7 = GUICtrlCreateInput("", 96, 192, 130, 20) $autobus8 = GUICtrlCreateInput("", 96, 212, 130, 20) $autobus9 = GUICtrlCreateInput("", 96, 232, 130, 20) $FileList=_FileListToArray("C:\Database\Autobus\") GUICtrlSetData($nombres, $FileList[0]) GUICtrlSetData($autobus, $FileList[1]) GUICtrlSetData($autobus1, $FileList[2]) GUICtrlSetData($autobus2, $FileList[3]) GUICtrlSetData($autobus3, $FileList[4]) GUICtrlSetData($autobus4, $FileList[5]) GUICtrlSetData($autobus5, $FileList[6]) GUICtrlSetData($autobus6, $FileList[7]) GUICtrlSetData($autobus7, $FileList[8]) GUICtrlSetData($autobus8, $FileList[9]) GUICtrlSetData($autobus9, $FileList[10]) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd Exit Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 2, 2006 Moderators Share Posted June 2, 2006 See if this works for you:#Include <File.au3> #include <GuiConstants.au3> Global $autobus[11] Global $FileList=_FileListToArray("C:\Database\Autobus\") $main = GuiCreate("MyGUI", 800, 600,-1, -1 ) $label1 = GUICtrlCreateLabel("Number", 10, 32) $nombres = GUICtrlCreateInput("", 96, 32, 30, 20) For $i = 1 To UBound($FileList) - 1 If $i > 10 Then ExitLoop ; If the file has more than 10 files, it will only list the first 10 $autobus[$i] = GUICtrlCreateInput("", 96, 32 + ($i * 20), 130, 20) GUICtrlSetData($autobus[$i], $FileList[$i]) Next GUICtrlSetData($nombres, $FileList[0]) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd P.S., Thanks for using code tags 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 More sharing options...
melf Posted June 3, 2006 Author Share Posted June 3, 2006 Sorry about that..will do next time Thx again for the help 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