Simmy Posted June 14, 2011 Share Posted June 14, 2011 (edited) Hi guys hope you are all well. Id like to learn how to populate a combo box with filenames (no extensions) from a directory. The folder can have any type of file, but I only want to grab files with a *.txt extension. Ideally Id like to be able to sort the combox alphabetically. I have attached a picture to show you what I am trying to do. Any help greatly appreciated. Edited June 14, 2011 by Simmy Link to comment Share on other sites More sharing options...
enaiman Posted June 14, 2011 Share Posted June 14, 2011 _FileListToArray - will get you the list of the files Make a string "|" delimited from all array elements (without element [0] which is the total count) then use GuiCtrlSetData to populate the combo. To have it sorted: create the combo with $CBS_SORT option. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
Simmy Posted June 14, 2011 Author Share Posted June 14, 2011 Hi Mass Spammer, thank you SO much for your kind help. Really appreciate it. Link to comment Share on other sites More sharing options...
Simmy Posted June 14, 2011 Author Share Posted June 14, 2011 Hi Mass Spammer, This is what I have so far: #Include <File.au3> #Include <Array.au3> ;============================================== ;Get list of files into an array: ;============================================== $FileList=_FileListToArray("c:\autoittest\me","*.txt",1) ;============================================== ;Error handling: ;============================================== If @Error=1 Then MsgBox (0,"","No Folders Found.") Exit EndIf If @Error=4 Then MsgBox (0,"","No Files Found.") Exit EndIf _ArrayDisplay($FileList,"$FileList") ;msgbox(0,"Details",$FileList[1]) What I'm not quite sure about is: a)How to convert the array/delimit the array by a "|" b)Start at index 2 without the count. Link to comment Share on other sites More sharing options...
enaiman Posted June 14, 2011 Share Posted June 14, 2011 lol - the nickname is a bit upper - on the blue line You need to use a For/Next loop: $string = "" For $i = 1 To $FileList[0] $string &= $FileList[$i]&"|" Next You need to read a bit more about arrays. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
Simmy Posted June 14, 2011 Author Share Posted June 14, 2011 I'm embarrassed now lol Sorry enaiman I ran the for next code and placed a msgbox with $string to see what the value of $string is. It was as follows: First time through: Textfile1.txt | Second time through: Textile1.txt | Textfile2.txt | Third time through: Textfile1.txt | Textfile2.txt | Textfile3.txt | Does that mean, I need to grab the content of the last time through the loop, and work with that line? Eg. The Textfile1.txt | Textfile2.txt | Textfile3.txt Link to comment Share on other sites More sharing options...
Simmy Posted June 14, 2011 Author Share Posted June 14, 2011 Thanks guys for your help, I'll do some more reading. Link to comment Share on other sites More sharing options...
czardas Posted June 14, 2011 Share Posted June 14, 2011 Does this help? #Include <File.au3> #Include <Array.au3> $FileList=_FileListToArray(@DesktopDir, "*.txt") If @Error=1 Then MsgBox (0,"","No Folders Found.") Exit EndIf If @Error=4 Then MsgBox (0,"","No Files Found.") Exit EndIf For $i = 0 To $FileList[0] $FileList[$i] = StringTrimRight($FileList[$i], 4) Next _ArrayDisplay($FileList,"$FileList") operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
guinness Posted June 14, 2011 Share Posted June 14, 2011 What about _GUICtrlComboBox_AddDir()? Although it will show .txt at the end of the filename, but its good to know for the future. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Simmy Posted June 14, 2011 Author Share Posted June 14, 2011 Thanks czardas (yes it does help mate). Thank you to all of you. Ill keep reading. Link to comment Share on other sites More sharing options...
Simmy Posted June 15, 2011 Author Share Posted June 15, 2011 Guys, with _ArrayDisplay($FileList,"$FileList"), is it possible to only show 1 column and not both? My attachment shows you what I mean. Link to comment Share on other sites More sharing options...
guinness Posted June 15, 2011 Share Posted June 15, 2011 (edited) Your best bet is to create you own using the ListView Functions. Have a look on the Forum OR at _ArrayDisplay() to get an idea of what to do. Also in my signature there are Examples starting with _GUICtrlListView_ which have an Example of a ListView or two. Edited June 15, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Simmy Posted June 15, 2011 Author Share Posted June 15, 2011 Thanks Guiness really appreciate it mate. 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