|
#1
|
||||
|
||||
Making a Document BrowserDocument ID: IR10050The information in this article applies to:
SUMMARYThis article describes how to make a document browser DISCUSSIONAs an example, we will create an application that has the user select a folder on his drive, and then populates a listbox object with all of the *.doc files within that directory. The user clicks on a file in the listbox object, and clicks the "Open" button to open the document.
MORE INFORMATIONKEYWORDS: AutoPlay Media Studio 5.0, Document, Browser Last reviewed: September 26, 2003 Copyright © 2003 Indigo Rose Corporation. All rights reserved.
__________________
Setup Factory 8.0 comes with over 250 actions so you can create smaller, faster and more intelligent software installers than ever before. WebHelp Guides: AMS | MSIFACT | SUF | TU | VP |
|
#2
|
||||
|
||||
|
Error Message Pops Up If No File Exist
Hi,
I tested this example. The FILE BROWSER OPENS. Good. However, when I attempted to LOAD a FOLDER that contains NONE of the .doc files, this error message appears: ON CLICK, Line 11: attempt to call nil value. How do I get rid of this error message? Better still, a message will appear saying that no such files, and tell us to try another folder. Thanks Azman |
|
#3
|
||||
|
||||
|
In the section where you enumerate the files.
Code:
for j,file_path in file do
--add the item to the listbox, with the name visible and path as data
ListBox.AddItem("ListBox1", String.SplitPath(file_path).Filename, file_path);
end
Code:
if file then
for j,file_path in file do
--add the item to the listbox, with the name visible and path as data
ListBox.AddItem("ListBox1", String.SplitPath(file_path).Filename, file_path);
end
end
Tigg
__________________
TJ-Tigger "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools." "Draco dormiens nunquam titillandus." Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine |
|
#4
|
||||
|
||||
|
Another way
Hi Tigg,
And this is what Adam suggested and works as well. Code:
if file ~= nil then
--do the following for each file:
for j,file_path in file do
--add the item to the listbox, with the name visible and path as data
ListBox.AddItem("ListBox1", String.SplitPath(file_path).Filename, file_path);
end
--Allow the listbox to display the updated content
ListBox.SetUpdate("ListBox1", true);
else
Dialog.Message("Notice","No Documents were found in that directory");
end
Azman |
|
#5
|
||||
|
||||
|
More File Types
Hi,
How would look for more than 1 file type. Say, I would like to search for .doc and .ppt at the same time from the same folder? So, if this is the case, how could I actually display even the file extensions to differentiate between the 2 types. Any ideas? I'm not a programmer , so I need some practical ideas as a kick-start. Thanks Azman |
|
#6
|
||||
|
||||
|
Here is an example of what I have done in the past
Code:
--Get the desired folder to browse
folder = Dialog.FolderBrowse("Open Folder", "C:\\");
tbSearchFiles = {"*.doc", "*.ppt"};
for index,type in tbSearchFiles do
file = File.Find(folder, type, false, false, nil);
if file ~= nil then
--do the following for each file:
for j,file_path in file do
--add the item to the listbox, with the name visible and path as data
ListBox.AddItem("ListBox1", String.SplitPath(file_path).Filename, file_path);
end
else
Dialog.Message("Notice","No Documents were found in that directory");
end
end
--Allow the listbox to display the updated content
ListBox.SetUpdate("ListBox1", true);
Hope this helps. If I can find it again, this is also on the forums somewhere out there. Tigg
__________________
TJ-Tigger "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools." "Draco dormiens nunquam titillandus." Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine |
|
#7
|
||||
|
||||
|
Here is another version of the above code that I posted on the forums before
http://www.indigorose.com/forums/showthread.php?t=6864
__________________
TJ-Tigger "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools." "Draco dormiens nunquam titillandus." Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine |
|
#8
|
||||
|
||||
|
Both Worked Well
Hi Tigg,
Both scripts worked very well. One item is missing, i.e. The File Extension. When we list in the ListBox only the filenames can be seen. What do we need to do to show the File Extensions? Thanks Azman |
|
#9
|
||||
|
||||
|
The splitpath command was used when added to a listbox and it did not include the extension. Try this.
Code:
--Get the desired folder to browse
folder = Dialog.FolderBrowse("Open Folder", "C:\\");
tbSearchFiles = {"*.doc", "*.ppt"};
for index,type in tbSearchFiles do
file = File.Find(folder, type, false, false, nil);
if file ~= nil then
--do the following for each file:
for j,file_path in file do
--add the item to the listbox, with the name visible and path as data
tbFilePath = String.SplitPath(file_path);
ListBox.AddItem("ListBox1", tbFilePath.Filename..tbFilePath.Extension, file_path);
end
else
Dialog.Message("Notice","No Documents were found in that directory");
end
end
--Allow the listbox to display the updated content
ListBox.SetUpdate("ListBox1", true);
__________________
TJ-Tigger "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools." "Draco dormiens nunquam titillandus." Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine |
|
#10
|
|||
|
|||
|
Aloha
Working with listbox in a DEMO (before I shell out my money). I understand the script - but - how do I make it look at multiple drives for a specific folder. Not knowing which drive the CD will be in on different machines - but knowing the folder name, how do I do this? I tried result = Dialog.FolderBrowse("Please select a folder:", "AutoPlay\\MyFolderName"); and modified this line to look for .ZIP files instead of .doc files file = File.Find(folder, "*.zip", false, false, nil); When I click "Load" - it opens a pop-up that lists my "C:/My Documents" instead of going to the Folder that I specified. Any ideas? Or is this just because it is in Preview mode and only looking at what I created and saved on my "C" drive. Also, is it possible to open a .zip and then open a .pdf or .doc or .whatever after - all in one smooth move? Please bear with me - I am still learning. Thanks in advance Lar |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
All times are GMT -6. The time now is 06:37 AM.






Linear Mode
