FUNCTION: FillListBoxFromFolder

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • RizlaUK
    Indigo Rose Customer
    • May 2006
    • 5552

    FUNCTION: FillListBoxFromFolder

    Hi Guys

    heres is 2 variations of a small function that will fill a listbox with the contents of the selected folder

    this variation will present the user with a folder browse dialog and load the files from the selected folder
    Code:
    [b][COLOR='#0000FF']function[/COLOR][/b] FillListBoxFromFolderDialog[COLOR='#FF0000']([/COLOR]LB[COLOR='#FF0000'])[/COLOR] 
    	folder [COLOR='#FF0000']=[/COLOR] Dialog[COLOR='#FF0000'].[/COLOR]FolderBrowse[COLOR='#FF0000']([/COLOR] [COLOR='#800080']"Open Folder"[/COLOR][COLOR='#FF0000'],[/COLOR] _DesktopFolder[COLOR='#FF0000'])[/COLOR]; 
    	[b][COLOR='#0000FF']if[/COLOR][/b] folder [COLOR='#FF0000']~[/COLOR][COLOR='#FF0000']=[/COLOR] [COLOR='#800080']"CANCEL"[/COLOR] [b][COLOR='#0000FF']then[/COLOR][/b] 
    		ListBox[COLOR='#FF0000'].[/COLOR]SetUpdate[COLOR='#FF0000']([/COLOR]LB[COLOR='#FF0000'],[/COLOR] false[COLOR='#FF0000'])[/COLOR]; 
    		ListBox[COLOR='#FF0000'].[/COLOR]DeleteItem[COLOR='#FF0000']([/COLOR]LB[COLOR='#FF0000'],[/COLOR] [COLOR='#FF0000']-[/COLOR]1[COLOR='#FF0000'])[/COLOR]; 
    		 [i][COLOR='#008000']	-- Set Default Extension[/COLOR][/i]
    		 [i][COLOR='#008000']	-- tbSearchFiles = {"*.doc", "*.ppt", "*.odt", "*.exe"}; set your own file types here[/COLOR][/i]
    		 [i][COLOR='#008000']	-- this one search all types[/COLOR][/i]
    			tbSearchFiles [COLOR='#FF0000']=[/COLOR] [COLOR='#FF0000']{[/COLOR] [COLOR='#800080']"*.*"[/COLOR][COLOR='#FF0000']}[/COLOR]; 
    			[b][COLOR='#0000FF']for[/COLOR][/b] index[COLOR='#FF0000'],[/COLOR]type [b][COLOR='#0000FF']in[/COLOR][/b] tbSearchFiles [b][COLOR='#0000FF']do[/COLOR][/b] 
    		       file [COLOR='#FF0000']=[/COLOR] File[COLOR='#FF0000'].[/COLOR]Find[COLOR='#FF0000']([/COLOR]folder[COLOR='#FF0000'],[/COLOR] type[COLOR='#FF0000'],[/COLOR] false[COLOR='#FF0000'],[/COLOR] false[COLOR='#FF0000'],[/COLOR] [b][COLOR='#0000FF']nil[/COLOR][/b][COLOR='#FF0000'])[/COLOR]; 
    		       	[b][COLOR='#0000FF']if[/COLOR][/b] file [COLOR='#FF0000']~[/COLOR][COLOR='#FF0000']=[/COLOR] [b][COLOR='#0000FF']nil[/COLOR][/b] then 
    	              [b][COLOR='#0000FF']for[/COLOR][/b] j[COLOR='#FF0000'],[/COLOR]file_path [b][COLOR='#0000FF']in[/COLOR][/b] file [b][COLOR='#0000FF']do[/COLOR][/b] 
    	                 tbFilePath [COLOR='#FF0000']=[/COLOR] String[COLOR='#FF0000'].[/COLOR]SplitPath[COLOR='#FF0000']([/COLOR]file_path[COLOR='#FF0000'])[/COLOR]; 
    	                 sFile [COLOR='#FF0000']=[/COLOR] tbFilePath[COLOR='#FF0000'].[/COLOR]Filename[COLOR='#FF0000'].[/COLOR][COLOR='#FF0000'].[/COLOR]tbFilePath[COLOR='#FF0000'].[/COLOR]Extension; 
    	                 ListBox[COLOR='#FF0000'].[/COLOR]AddItem[COLOR='#FF0000']([/COLOR]LB[COLOR='#FF0000'],[/COLOR] sFile[COLOR='#FF0000'],[/COLOR] file_path[COLOR='#FF0000'])[/COLOR];                                      
    	              [b][COLOR='#0000FF']end[/COLOR][/b] 
    		       	[b][COLOR='#0000FF']end[/COLOR][/b] 
    			[b][COLOR='#0000FF']end[/COLOR][/b] 
    		ListBox[COLOR='#FF0000'].[/COLOR]SetUpdate[COLOR='#FF0000']([/COLOR]LB[COLOR='#FF0000'],[/COLOR] true[COLOR='#FF0000'])[/COLOR]; 
    	[b][COLOR='#0000FF']end[/COLOR][/b] 
    [b][COLOR='#0000FF']end[/COLOR][/b]
    and call the function with the listbox name
    Code:
    FillListBoxFromFolderDialog[COLOR='#FF0000']([/COLOR] [COLOR='#800080']"ListBox1"[/COLOR][COLOR='#FF0000'])[/COLOR]

    this variation uses a predefined folder
    Code:
    [b][COLOR='#0000FF']function[/COLOR][/b] FillListBoxFromFolder[COLOR='#FF0000']([/COLOR]folder[COLOR='#FF0000'],[/COLOR] LB[COLOR='#FF0000'])[/COLOR] 
    	isfolder [COLOR='#FF0000']=[/COLOR] Folder[COLOR='#FF0000'].[/COLOR]DoesExist[COLOR='#FF0000']([/COLOR]folder[COLOR='#FF0000'])[/COLOR]; 
    	[b][COLOR='#0000FF']if[/COLOR][/b] isfolder [b][COLOR='#0000FF']then[/COLOR][/b] 
    		ListBox[COLOR='#FF0000'].[/COLOR]SetUpdate[COLOR='#FF0000']([/COLOR]LB[COLOR='#FF0000'],[/COLOR] false[COLOR='#FF0000'])[/COLOR]; 
    		ListBox[COLOR='#FF0000'].[/COLOR]DeleteItem[COLOR='#FF0000']([/COLOR]LB[COLOR='#FF0000'],[/COLOR] [COLOR='#FF0000']-[/COLOR]1[COLOR='#FF0000'])[/COLOR]; 
    		 [i][COLOR='#008000']	-- Set Default Extension[/COLOR][/i]
    		 [i][COLOR='#008000']	-- tbSearchFiles = {"*.doc", "*.ppt", "*.odt", "*.exe"}; set your own file types here[/COLOR][/i]
    		 [i][COLOR='#008000']	-- this one search all types[/COLOR][/i]
    			tbSearchFiles [COLOR='#FF0000']=[/COLOR] [COLOR='#FF0000']{[/COLOR] [COLOR='#800080']"*.*"[/COLOR][COLOR='#FF0000']}[/COLOR]; 
    			[b][COLOR='#0000FF']for[/COLOR][/b] index[COLOR='#FF0000'],[/COLOR]type [b][COLOR='#0000FF']in[/COLOR][/b] tbSearchFiles [b][COLOR='#0000FF']do[/COLOR][/b] 
    		       file [COLOR='#FF0000']=[/COLOR] File[COLOR='#FF0000'].[/COLOR]Find[COLOR='#FF0000']([/COLOR]folder[COLOR='#FF0000'],[/COLOR] type[COLOR='#FF0000'],[/COLOR] false[COLOR='#FF0000'],[/COLOR] false[COLOR='#FF0000'],[/COLOR] [b][COLOR='#0000FF']nil[/COLOR][/b][COLOR='#FF0000'])[/COLOR]; 
    		       	[b][COLOR='#0000FF']if[/COLOR][/b] file [COLOR='#FF0000']~[/COLOR][COLOR='#FF0000']=[/COLOR] [b][COLOR='#0000FF']nil[/COLOR][/b] then 
    	              [b][COLOR='#0000FF']for[/COLOR][/b] j[COLOR='#FF0000'],[/COLOR]file_path [b][COLOR='#0000FF']in[/COLOR][/b] file [b][COLOR='#0000FF']do[/COLOR][/b] 
    	                 tbFilePath [COLOR='#FF0000']=[/COLOR] String[COLOR='#FF0000'].[/COLOR]SplitPath[COLOR='#FF0000']([/COLOR]file_path[COLOR='#FF0000'])[/COLOR]; 
    	                 sFile [COLOR='#FF0000']=[/COLOR] tbFilePath[COLOR='#FF0000'].[/COLOR]Filename[COLOR='#FF0000'].[/COLOR][COLOR='#FF0000'].[/COLOR]tbFilePath[COLOR='#FF0000'].[/COLOR]Extension; 
    	                 ListBox[COLOR='#FF0000'].[/COLOR]AddItem[COLOR='#FF0000']([/COLOR]LB[COLOR='#FF0000'],[/COLOR] sFile[COLOR='#FF0000'],[/COLOR] file_path[COLOR='#FF0000'])[/COLOR];                                      
    	              [b][COLOR='#0000FF']end[/COLOR][/b] 
    		       	[b][COLOR='#0000FF']end[/COLOR][/b] 
    			[b][COLOR='#0000FF']end[/COLOR][/b] 
    		ListBox[COLOR='#FF0000'].[/COLOR]SetUpdate[COLOR='#FF0000']([/COLOR]LB[COLOR='#FF0000'],[/COLOR] true[COLOR='#FF0000'])[/COLOR]; 
    	[b][COLOR='#0000FF']end[/COLOR][/b] 
    [b][COLOR='#0000FF']end[/COLOR][/b]
    and call this function with the target folder and the listbox name
    Code:
    [FONT='Courier New'][SIZE='2']
    FillListBoxFromFolder[COLOR='#FF0000']([/COLOR] [COLOR='#800080']"AutoPlay\\Docs"[/COLOR][COLOR='#FF0000'],[/COLOR] [COLOR='#800080']"ListBox1"[/COLOR][COLOR='#FF0000'])[/COLOR] [/SIZE][/FONT]


    output enhanced with AMS Code Pretty

    Have fun
    Embrace change in your life, you never know, it could all work out for the best
  • Desolator
    Forum Member
    • Apr 2007
    • 292

    #2
    This does the same as both, though I haven't tested it:

    Code:
    function ListBoxAddFolder(strListBox, strFolderPath)
    	if not strFolderPath then
    		strFolderPath = Dialog.FolderBrowse("Open Folder", _DesktopFolder);
    	end
    
    	ListBox.SetUpdate(LB, false);
    	ListBox.DeleteItem(LB, -1);
    
    	local tblSearchFiles = { "*.*"};
    
    	for numSearchIndex, strFile in tblSearchFiles do
    		local tblFoundFiles = File.Find(strFolderPath, strFile, true, false, nil);
    
    		if tblFoundFiles then
    			for numFileIndex, strFilePath in tblFoundFiles do
    				tblFilePath = String.SplitPath(strFilePath);
    				ListBox.AddItem(strListBox, tblFilePath.Filename .. tblFilePath.Extension, strFilePath);
    			end
    		end
    	end
    
    	ListBox.SetUpdate(LB, true); 
    end
    
    ListBox.AddFolder = ListBoxAddFolder;

    Comment

    • RizlaUK
      Indigo Rose Customer
      • May 2006
      • 5552

      #3
      lol, ok

      heres the same function that dose both...(and it is tested)

      Code:
      function FillListBoxFromFolder(folder, LB)
      	
      	if folder == "" then
      		folder = Dialog.FolderBrowse("Open Folder", _DesktopFolder);
      	end
      
      	isfolder = Folder.DoesExist(folder);
      	if isfolder then
      		ListBox.SetUpdate(LB, false);
      		ListBox.DeleteItem(LB, -1);
      			-- Set Default Extension
      			-- tbSearchFiles = {"*.doc", "*.ppt", "*.odt", "*.exe"}; set your own file types here
      			-- this one search all types
      			tbSearchFiles = {"*.*"};
      			for index,type in tbSearchFiles do
      		       file = File.Find(folder, type, false, false, nil);
      		       	if file ~= nil then
      	              for j,file_path in file do
      	                 tbFilePath = String.SplitPath(file_path);
      	                 sFile = tbFilePath.Filename..tbFilePath.Extension;
      	                 ListBox.AddItem(LB, sFile, file_path);                                      
      	              end
      		       	end
      			end
      		ListBox.SetUpdate(LB, true); 
      	end
      end
      to make it show the folder browse dialog call the function like this
      Code:
      FillListBoxFromFolder("", "ListBox1")
      to use a predefined folder call it like this
      Code:
      FillListBoxFromFolder("AutoPlay\\Docs", "ListBox1")

      and for combo box

      Code:
      function FillComboFromFolder(folder, CB)
      	
      	if folder == "" then
      		folder = Dialog.FolderBrowse("Open Folder", _DesktopFolder);
      	end
      
      	isfolder = Folder.DoesExist(folder);
      	if isfolder then
      		ComboBox.SetUpdate(CB, false);
      		ComboBox.ResetContent(CB);
      			-- Set Default Extension
      			-- tbSearchFiles = {"*.doc", "*.ppt", "*.odt", "*.exe"}; set your own file types here
      			-- this one search all types
      			tbSearchFiles = {"*.*"};
      			for index,type in tbSearchFiles do
      		       file = File.Find(folder, type, false, false, nil);
      		       	if file ~= nil then
      	              for j,file_path in file do
      	                 tbFilePath = String.SplitPath(file_path);
      	                 sFile = tbFilePath.Filename..tbFilePath.Extension;
      	                 ComboBox.AddItem(CB, sFile, file_path);                                     
      	              end
      		       	end
      			end
      		ComboBox.SetUpdate(CB, true);
      	end
      end
      to make it show the folder browse dialog call the function like this
      Code:
      FillComboFromFolder("", "ComboBox1")
      to use a predefined folder call it like this
      Code:
      FillComboFromFolder("AutoPlay\\Docs", "ComboBox1")
      Embrace change in your life, you never know, it could all work out for the best

      Comment

      • Desolator
        Forum Member
        • Apr 2007
        • 292

        #4
        And this also does both for both LB and CB:

        Code:
        function FillListFromFolder(folder, obj)
        	if Page.GetObjectType("Cmd_Input") == OBJECT_LISTBOX then
        		if folder == "" then
        			folder = Dialog.FolderBrowse("Open Folder", _DesktopFolder);
        		end
        
        		isfolder = Folder.DoesExist(folder);
        		if isfolder then
        			ListBox.SetUpdate(obj, false);
        			ListBox.DeleteItem(obj, -1);
        				-- Set Default Extension
        				-- tbSearchFiles = {"*.doc", "*.ppt", "*.odt", "*.exe"}; set your own file types here
        				-- this one search all types
        				tbSearchFiles = {"*.*"};
        				for index,type in tbSearchFiles do
        			       file = File.Find(folder, type, false, false, nil);
        			       	if file ~= nil then
        		              for j,file_path in file do
        		                 tbFilePath = String.SplitPath(file_path);
        		                 sFile = tbFilePath.Filename..tbFilePath.Extension;
        		                 ListBox.AddItem(obj, sFile, file_path);                                      
        		              end
        			       	end
        				end
        			ListBox.SetUpdate(obj, true); 
        		end
        	elseif Page.GetObjectType("Cmd_Input") == OBJECT_COMBOBOX then
        		if folder == "" then
        			folder = Dialog.FolderBrowse("Open Folder", _DesktopFolder);
        		end
        
        		isfolder = Folder.DoesExist(folder);
        		if isfolder then
        			ComboBox.SetUpdate(obj, false);
        			ComboBox.ResetContent(obj);
        				-- Set Default Extension
        				-- tbSearchFiles = {"*.doc", "*.ppt", "*.odt", "*.exe"}; set your own file types here
        				-- this one search all types
        				tbSearchFiles = {"*.*"};
        				for index,type in tbSearchFiles do
        			       file = File.Find(folder, type, false, false, nil);
        			       	if file ~= nil then
        		              for j,file_path in file do
        		                 tbFilePath = String.SplitPath(file_path);
        		                 sFile = tbFilePath.Filename..tbFilePath.Extension;
        		                 ComboBox.AddItem(obj, sFile, file_path);                                     
        		              end
        			       	end
        				end
        			ComboBox.SetUpdate(obj, true);
        		end
        	end
        end

        Comment

        • RizlaUK
          Indigo Rose Customer
          • May 2006
          • 5552

          #5
          nice, but dose it work and whats the function call ??
          Embrace change in your life, you never know, it could all work out for the best

          Comment

          • Desolator
            Forum Member
            • Apr 2007
            • 292

            #6
            Same as yours:
            FillListFromFolder("C:\My Folder", "ListBox1");
            FillListFromFolder("C:\My Folder", "ComboBox1");

            It detects the type automatically...well, if I didn't miss something:

            Code:
            function FillListFromFolder(folder, obj)
            	if Page.GetObjectType([COLOR="Red"]obj[/COLOR]) == OBJECT_LISTBOX then
            		if folder == "" then
            			folder = Dialog.FolderBrowse("Open Folder", _DesktopFolder);
            		end
            
            		isfolder = Folder.DoesExist(folder);
            		if isfolder then
            			ListBox.SetUpdate(obj, false);
            			ListBox.DeleteItem(obj, -1);
            				-- Set Default Extension
            				-- tbSearchFiles = {"*.doc", "*.ppt", "*.odt", "*.exe"}; set your own file types here
            				-- this one search all types
            				tbSearchFiles = {"*.*"};
            				for index,type in tbSearchFiles do
            			       file = File.Find(folder, type, false, false, nil);
            			       	if file ~= nil then
            		              for j,file_path in file do
            		                 tbFilePath = String.SplitPath(file_path);
            		                 sFile = tbFilePath.Filename..tbFilePath.Extension;
            		                 ListBox.AddItem(obj, sFile, file_path);                                      
            		              end
            			       	end
            				end
            			ListBox.SetUpdate(obj, true); 
            		end
            	elseif Page.GetObjectType([COLOR="Red"]obj[/COLOR]) == OBJECT_COMBOBOX then
            		if folder == "" then
            			folder = Dialog.FolderBrowse("Open Folder", _DesktopFolder);
            		end
            
            		isfolder = Folder.DoesExist(folder);
            		if isfolder then
            			ComboBox.SetUpdate(obj, false);
            			ComboBox.ResetContent(obj);
            				-- Set Default Extension
            				-- tbSearchFiles = {"*.doc", "*.ppt", "*.odt", "*.exe"}; set your own file types here
            				-- this one search all types
            				tbSearchFiles = {"*.*"};
            				for index,type in tbSearchFiles do
            			       file = File.Find(folder, type, false, false, nil);
            			       	if file ~= nil then
            		              for j,file_path in file do
            		                 tbFilePath = String.SplitPath(file_path);
            		                 sFile = tbFilePath.Filename..tbFilePath.Extension;
            		                 ComboBox.AddItem(obj, sFile, file_path);                                     
            		              end
            			       	end
            				end
            			ComboBox.SetUpdate(obj, true);
            		end
            	end
            end

            Comment

            • Desolator
              Forum Member
              • Apr 2007
              • 292

              #7
              Tested, made more readable:

              Code:
              01 [b][COLOR='#0000FF']function[/COLOR][/b] FillListFromFolder[COLOR='#FF0000']([/COLOR]strObject[COLOR='#FF0000'],[/COLOR] strFolder[COLOR='#FF0000'])[/COLOR] 
              02 	[b][COLOR='#0000FF']local[/COLOR][/b] tblSearchFiles [COLOR='#FF0000']=[/COLOR] [COLOR='#FF0000']{[/COLOR] [COLOR='#800080']"*.*"[/COLOR][COLOR='#FF0000']}[/COLOR]; 
              03 	[b][COLOR='#0000FF']local[/COLOR][/b] numObjectType [COLOR='#FF0000']=[/COLOR] Page[COLOR='#FF0000'].[/COLOR]GetObjectType[COLOR='#FF0000']([/COLOR]strObject[COLOR='#FF0000'])[/COLOR]; 
              04 
              05 	[b][COLOR='#0000FF']if[/COLOR][/b] numObjectType [COLOR='#FF0000']=[/COLOR][COLOR='#FF0000']=[/COLOR] 9 [b][COLOR='#0000FF']then[/COLOR][/b] 
              06 		[b][COLOR='#0000FF']if[/COLOR][/b] [b][COLOR='#0000FF']not[/COLOR][/b] strFolder [b][COLOR='#0000FF']then[/COLOR][/b] 
              07 			strFolder [COLOR='#FF0000']=[/COLOR] Dialog[COLOR='#FF0000'].[/COLOR]FolderBrowse[COLOR='#FF0000']([/COLOR] [COLOR='#800080']"Open Folder"[/COLOR][COLOR='#FF0000'],[/COLOR] _DesktopFolder[COLOR='#FF0000'])[/COLOR]; 
              08 		[b][COLOR='#0000FF']end[/COLOR][/b] 
              09 
              10 		[b][COLOR='#0000FF']if[/COLOR][/b] Folder[COLOR='#FF0000'].[/COLOR]DoesExist[COLOR='#FF0000']([/COLOR]strFolder[COLOR='#FF0000'])[/COLOR] [b][COLOR='#0000FF']then[/COLOR][/b] 
              11 			ListBox[COLOR='#FF0000'].[/COLOR]SetUpdate[COLOR='#FF0000']([/COLOR]strObject[COLOR='#FF0000'],[/COLOR] false[COLOR='#FF0000'])[/COLOR]; 
              12 			ListBox[COLOR='#FF0000'].[/COLOR]DeleteItem[COLOR='#FF0000']([/COLOR]strObject[COLOR='#FF0000'],[/COLOR] [COLOR='#FF0000']-[/COLOR]1[COLOR='#FF0000'])[/COLOR]; 
              13 
              14 			[b][COLOR='#0000FF']for[/COLOR][/b] numIndex[COLOR='#FF0000'],[/COLOR] strFile [b][COLOR='#0000FF']in[/COLOR][/b] tblSearchFiles [b][COLOR='#0000FF']do[/COLOR][/b] 
              15 				tblFilesFound [COLOR='#FF0000']=[/COLOR] File[COLOR='#FF0000'].[/COLOR]Find[COLOR='#FF0000']([/COLOR]strFolder[COLOR='#FF0000'],[/COLOR] strFile[COLOR='#FF0000'],[/COLOR] true[COLOR='#FF0000'],[/COLOR] false[COLOR='#FF0000'],[/COLOR] [b][COLOR='#0000FF']nil[/COLOR][/b][COLOR='#FF0000'])[/COLOR]; 
              16 
              17 				[b][COLOR='#0000FF']if[/COLOR][/b] tblFilesFound [b][COLOR='#0000FF']then[/COLOR][/b] 
              18 					[b][COLOR='#0000FF']for[/COLOR][/b] numIndex[COLOR='#FF0000'],[/COLOR] strFileFound [b][COLOR='#0000FF']in[/COLOR][/b] tblFilesFound [b][COLOR='#0000FF']do[/COLOR][/b] 
              19 						[b][COLOR='#0000FF']local[/COLOR][/b] tblFilePath [COLOR='#FF0000']=[/COLOR] String[COLOR='#FF0000'].[/COLOR]SplitPath[COLOR='#FF0000']([/COLOR]strFileFound[COLOR='#FF0000'])[/COLOR]; 
              20 						ListBox[COLOR='#FF0000'].[/COLOR]AddItem[COLOR='#FF0000']([/COLOR]strObject[COLOR='#FF0000'],[/COLOR] tblFilePath[COLOR='#FF0000'].[/COLOR]Filename [COLOR='#FF0000'].[/COLOR][COLOR='#FF0000'].[/COLOR] tblFilePath[COLOR='#FF0000'].[/COLOR]Extension[COLOR='#FF0000'],[/COLOR] strFileFound[COLOR='#FF0000'])[/COLOR]; 
              21 					[b][COLOR='#0000FF']end[/COLOR][/b] 
              22 				[b][COLOR='#0000FF']end[/COLOR][/b] 
              23 			[b][COLOR='#0000FF']end[/COLOR][/b] 
              24 
              25 			ListBox[COLOR='#FF0000'].[/COLOR]SetUpdate[COLOR='#FF0000']([/COLOR]strObject[COLOR='#FF0000'],[/COLOR] true[COLOR='#FF0000'])[/COLOR]; 
              26 		[b][COLOR='#0000FF']end[/COLOR][/b] 
              27 	[b][COLOR='#0000FF']elseif[/COLOR][/b] numObjectType [COLOR='#FF0000']=[/COLOR][COLOR='#FF0000']=[/COLOR] 10 [b][COLOR='#0000FF']then[/COLOR][/b] 
              28 		[b][COLOR='#0000FF']if[/COLOR][/b] [b][COLOR='#0000FF']not[/COLOR][/b] strFolder [b][COLOR='#0000FF']then[/COLOR][/b] 
              29 			strFolder [COLOR='#FF0000']=[/COLOR] Dialog[COLOR='#FF0000'].[/COLOR]FolderBrowse[COLOR='#FF0000']([/COLOR] [COLOR='#800080']"Open Folder"[/COLOR][COLOR='#FF0000'],[/COLOR] _DesktopFolder[COLOR='#FF0000'])[/COLOR]; 
              30 		[b][COLOR='#0000FF']end[/COLOR][/b] 
              31 
              32 		[b][COLOR='#0000FF']if[/COLOR][/b] Folder[COLOR='#FF0000'].[/COLOR]DoesExist[COLOR='#FF0000']([/COLOR]strFolder[COLOR='#FF0000'])[/COLOR] [b][COLOR='#0000FF']then[/COLOR][/b] 
              33 			ComboBox[COLOR='#FF0000'].[/COLOR]SetUpdate[COLOR='#FF0000']([/COLOR]strObject[COLOR='#FF0000'],[/COLOR] false[COLOR='#FF0000'])[/COLOR]; 
              34 			ComboBox[COLOR='#FF0000'].[/COLOR]ResetContent[COLOR='#FF0000']([/COLOR]strObject[COLOR='#FF0000'])[/COLOR]; 
              35 
              36 			[b][COLOR='#0000FF']for[/COLOR][/b] numIndex[COLOR='#FF0000'],[/COLOR] strFile [b][COLOR='#0000FF']in[/COLOR][/b] tblSearchFiles [b][COLOR='#0000FF']do[/COLOR][/b] 
              37 				tblFilesFound [COLOR='#FF0000']=[/COLOR] File[COLOR='#FF0000'].[/COLOR]Find[COLOR='#FF0000']([/COLOR]strFolder[COLOR='#FF0000'],[/COLOR] strFile[COLOR='#FF0000'],[/COLOR] true[COLOR='#FF0000'],[/COLOR] false[COLOR='#FF0000'],[/COLOR] [b][COLOR='#0000FF']nil[/COLOR][/b][COLOR='#FF0000'])[/COLOR]; 
              38 
              39 				[b][COLOR='#0000FF']if[/COLOR][/b] tblFilesFound [b][COLOR='#0000FF']then[/COLOR][/b] 
              40 					[b][COLOR='#0000FF']for[/COLOR][/b] numIndex[COLOR='#FF0000'],[/COLOR] strFileFound [b][COLOR='#0000FF']in[/COLOR][/b] tblFilesFound [b][COLOR='#0000FF']do[/COLOR][/b] 
              41 						[b][COLOR='#0000FF']local[/COLOR][/b] tblFilePath [COLOR='#FF0000']=[/COLOR] String[COLOR='#FF0000'].[/COLOR]SplitPath[COLOR='#FF0000']([/COLOR]strFileFound[COLOR='#FF0000'])[/COLOR]; 
              42 						ComboBox[COLOR='#FF0000'].[/COLOR]AddItem[COLOR='#FF0000']([/COLOR]strObject[COLOR='#FF0000'],[/COLOR] tblFilePath[COLOR='#FF0000'].[/COLOR]Filename [COLOR='#FF0000'].[/COLOR][COLOR='#FF0000'].[/COLOR] tblFilePath[COLOR='#FF0000'].[/COLOR]Extension[COLOR='#FF0000'],[/COLOR] strFileFound[COLOR='#FF0000'])[/COLOR]; 
              43 					[b][COLOR='#0000FF']end[/COLOR][/b] 
              44 				[b][COLOR='#0000FF']end[/COLOR][/b] 
              45 			[b][COLOR='#0000FF']end[/COLOR][/b] 
              46 
              47 			ComboBox[COLOR='#FF0000'].[/COLOR]SetUpdate[COLOR='#FF0000']([/COLOR]strObject[COLOR='#FF0000'],[/COLOR] true[COLOR='#FF0000'])[/COLOR]; 
              48 		[b][COLOR='#0000FF']end[/COLOR][/b] 
              49 	[b][COLOR='#0000FF']end[/COLOR][/b] 
              50 [b][COLOR='#0000FF']end[/COLOR][/b]
              output enhanced with AMS Code Pretty
              Last edited by Desolator; 06-12-2007, 08:16 AM.

              Comment

              • RizlaUK
                Indigo Rose Customer
                • May 2006
                • 5552

                #8
                just a lil hint, when using AMS Code Pretty to post code in the forum you should disable the numbering, it just makes it easyer to c&p the code :yes
                Embrace change in your life, you never know, it could all work out for the best

                Comment

                • Desolator
                  Forum Member
                  • Apr 2007
                  • 292

                  #9
                  Thanks for the tip. I'd make the function for the Tree Object, but the example is kinda confusing, not well-structured. Could you give it a shot, please?

                  Comment

                  • fmwyso
                    Forum Member
                    • Sep 2007
                    • 25

                    #10
                    Great Code .
                    Last edited by fmwyso; 09-22-2007, 08:34 PM.

                    Comment

                    Working...
                    X