Indigo Rose Software
  #1  
Old 01-20-2007
TristanD's Avatar
TristanD TristanD is offline
Forum Member
 
Join Date: Oct 2006
Location: Somewere over the rainbow
Posts: 314
Example : Populate a tree from Files in a Folder

The is an project i made on request.. It populates a tree object with files from a folder and when double click on a node it open the file

How to set it up Yourself :

Create a tree object..

On Global Functions:
Code:
function GetFolderContentsFromDialog()
folderbrowse = Dialog.FolderBrowse("Please select a folder:", _SourceDrive);
Zip = File.Find(folderbrowse, "*.rar", true, false, ShowSearchProgress, nil);
	if Zip then
		for i,v in Zip do
		tbSplit = String.SplitPath(v);
		name = tbSplit.Filename
			tblNodeData = {};
			tblNodeData.Text = name;
			tblNodeData.Data = v;
		Tree.InsertNode("Tree1", "3", tblNodeData);
		end
	end
end

function GetFolderContents()
Zip = File.Find(_SourceFolder, "*.rar", true, false, ShowSearchProgress, nil);
	if Zip then
		for i,v in Zip do
		tbSplit = String.SplitPath(v);
		name = tbSplit.Filename
			tblNodeData = {};
			tblNodeData.Text = name;
			tblNodeData.Data = v;
		Tree.InsertNode("Tree1", "3", tblNodeData);
		end
	end
end

function RunNodeFile()
sel_node = Tree.GetSelectedNode("Tree1");
node = Tree.GetNode("Tree1", sel_node);
node_data = node.Data
File.Open(node_data, "", SW_SHOWNORMAL);
end
On Show (two options possible)
1 Populate from a folder chosen with a dialog
Code:
GetFolderContentsFromDialog()
2 Populate From the sourcefolder
Code:
GetFolderContents()
Tree, On Double Click
Code:
RunNodeFile()
Thats it

If you dont feel like copy and pasting the whole time then use my prebuild project
Attached Files
File Type: apz Populate-Tree-From-Folder-TristanD.apz (116.6 KB, 851 views)
Reply With Quote
  #2  
Old 04-11-2007
1skram323's Avatar
1skram323 1skram323 is offline
Forum Member
 
Join Date: Jun 2006
Location: Middle of Nowhere Missouri
Posts: 19
help?

I am pretty new at this and was playing with the code that you posted.

could you please show me how to change the File.Run to file.copy to a set location?

thank you in advance, I am a novice coder and need all the help I can get.
Mark
Reply With Quote
  #3  
Old 04-16-2007
TristanD's Avatar
TristanD TristanD is offline
Forum Member
 
Join Date: Oct 2006
Location: Somewere over the rainbow
Posts: 314
On global function, change the red line into the blue one
Code:
function GetFolderContentsFromDialog()
folderbrowse = Dialog.FolderBrowse("Please select a folder:", _SourceDrive);
Zip = File.Find(folderbrowse, "*.rar", true, false, ShowSearchProgress, nil);
	if Zip then
		for i,v in Zip do
		tbSplit = String.SplitPath(v);
		name = tbSplit.Filename
			tblNodeData = {};
			tblNodeData.Text = name;
			tblNodeData.Data = v;
		Tree.InsertNode("Tree1", "3", tblNodeData);
		end
	end
end

function GetFolderContents()
Zip = File.Find(_SourceFolder, "*.rar", true, false, ShowSearchProgress, nil);
	if Zip then
		for i,v in Zip do
		tbSplit = String.SplitPath(v);
		name = tbSplit.Filename
			tblNodeData = {};
			tblNodeData.Text = name;
			tblNodeData.Data = v;
		Tree.InsertNode("Tree1", "3", tblNodeData);
		end
	end
end

function RunNodeFile()
sel_node = Tree.GetSelectedNode("Tree1");
node = Tree.GetNode("Tree1", sel_node);
node_data = node.Data
File.Open(node_data, "", SW_SHOWNORMAL);
 File.Copy(Node_Data, "C:\\MyDir\\", true, true, false, true, nil);
end
this will copy the selected file to your C drive
Reply With Quote
  #4  
Old 04-17-2007
1skram323's Avatar
1skram323 1skram323 is offline
Forum Member
 
Join Date: Jun 2006
Location: Middle of Nowhere Missouri
Posts: 19
Cool!

Thank you, I had tried that but had left something out!

I appreciate the help!
Mark
Reply With Quote
  #5  
Old 01-22-2008
HCASDG HCASDG is offline
Forum Member
 
Join Date: Jan 2008
Posts: 1
Lightbulb Code for Sorting?

Thanks for the code.

Any suggestions on how to enhance the GetFolderContents function to alphabetically sort the files that are retrieved?
Reply With Quote
  #6  
Old 01-22-2008
TimeSurfer's Avatar
TimeSurfer TimeSurfer is offline
Forum Member
 
Join Date: Dec 2007
Location: Colorado, United States
Posts: 323
you really shouldnt have to make it sort them. have the function load the files into a listbox or tree object and enable sort under object properties. you may also have to use set properties for your object in an on show or preload event. if you need any help let me know and i will try to get you a quick example
Reply With Quote
  #7  
Old 06-02-2008
pakapaka pakapaka is offline
Indigo Rose Customer
 
Join Date: Jan 2007
Posts: 131
Populate a tree from Files in a Folder

I am using the example project made by TristanD (..many many thanks if you are still around the Forum). The link is here

http://www.indigorose.com/forums/sho...node+open+file

Now I need to make a couple of slight modifications to the code as follows:

1) Instead of the default folder (c:\root..) I need to define a specific folder under the \autoplay\docs\ folder
2) When the tree is populated I need to hide the file extension (i.e not show *.pdf etc)
3) When I press a button, I need to refresh the tree (for the same folder) without showing a dialog box.

Perhaps I should mention that I am not using "rootfolder" input box or the "change" button inside the project

Can anybody help...I am not a programmer so your assistance is greatly appreciated.

Thanks
Pakapaka
Reply With Quote
  #8  
Old 06-03-2008
Imagine Programming's Avatar
Imagine Programming Imagine Programming is offline
Forum Member
 
Join Date: Apr 2007
Location: The Netherlands
Posts: 1,323
I don't think that thierry (Tristan) is still on the forum, he is programming in VB now... ah well, he made great examples ^^ i taught me programming in lua lol
Reply With Quote
  #9  
Old 07-03-2008
TristanD's Avatar
TristanD TristanD is offline
Forum Member
 
Join Date: Oct 2006
Location: Somewere over the rainbow
Posts: 314
Quote:
Originally Posted by C B programming and webdesign View Post
I don't think that thierry (Tristan) is still on the forum, he is programming in VB now... ah well, he made great examples ^^ i taught me programming in lua lol
Yeah i've switched from ams to Vb.Net but hey, im still around, willing to help wherever i can and i've learned alot in the mean time

Last edited by TristanD; 07-03-2008 at 05:35 AM. Reason: Me and My Typo's
Reply With Quote
  #10  
Old 07-03-2008
pakapaka pakapaka is offline
Indigo Rose Customer
 
Join Date: Jan 2007
Posts: 131
Thanks Tristan...I will rewrite my question and repost it
Maybe you can help
Reply With Quote
  #11  
Old 07-05-2008
TristanD's Avatar
TristanD TristanD is offline
Forum Member
 
Join Date: Oct 2006
Location: Somewere over the rainbow
Posts: 314
Go Ahead, Repost
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate listbox with files in docs folder by modified date wedgea09 AutoPlay Media Studio 6.0 0 04-10-2006 08:02 AM
Unable to find software? NigelLacey Visual Patch 2.0 4 10-11-2005 11:35 AM
cookies goukilord10 AutoPlay Media Studio 5.0 6 05-20-2005 05:08 PM
INFO: Why Files are Renamed in the DATA Folder Support AutoPlay Media Studio 4.0 Examples 0 10-24-2002 04:36 PM
INFO:The Files that are Built into the DATA Folder Support AutoPlay Media Studio 4.0 Examples 0 10-03-2002 04:15 PM


All times are GMT -6. The time now is 01:49 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software