PDA

View Full Version : Search File Code - Help Please!


John Fletcher
08-20-2007, 08:01 AM
Below is the complete code that I could find for the File Search AMS development produced by AZman - I attained this AMS development from http://www.azman.info This is a cool code yet I believe there are missing peramiters.

-- Page - on show --

-- Clears all items from combobox
ComboBox.ResetContent("ComboBox1");

-- Get a list of the available drives.
tDrives = Drive.Enumerate();

if tDrives then
for i,driveInfo in tDrives do
ComboBox.AddItem("ComboBox1", driveInfo, driveInfo);
end
end

ComboBox.SetSelected("ComboBox1", 1);


-- LB_FileListStep1 - on double click --


LB = "LB_FileListStep1";
-- Get the selected items
tSelected = ListBox.GetSelected(LB);

-- ListBox object, we are only concerned with tSelected[1]

if tSelected then
-- There is an item selected, get the data!
sFileToOpen = ListBox.GetItemData(LB, tSelected[1]);
File.Open(sFileToOpen, "McKesson", SW_SHOWNORMAL);
else
-- Display an error message
Dialog.Message("Error", "There is no item selected.");
end


-- LB_FileListStep1 - on select --

LB = "LB_FileListStep1";
-- Get the selected items
tSelected = ListBox.GetSelected(LB);

-- Because we are not allowing multiple select in the
-- ListBox object, we are only concerned with tSelected[1]

if tSelected then

-- There is an item selected, get the data!
sFile = ListBox.GetItemData(LB, tSelected[1]);
nSize = File.GetSize (sFile);
tFileAtt = File.GetAttributes (sFile);
sFileCreated = tFileAtt.CreationDate;
sFileLastAccess = tFileAtt.AccessDate;
sFileLastWritten = tFileAtt.WriteDate;

Paragraph.SetEnabled("Para_FileProps", false);

else
-- Display an error message
Dialog.Message("Error", "There is no item selected.");
end


-- Button1 - on click --

LB = "LB_FileListStep1";

ListBox.DeleteItem("LB_FileListStep1", -1);

sFileSearch = Input.GetText("Input_FileSearch");
if sFileSearch=="" then
Dialog.Message("Notice", "PLEASE ENTER FILE NAME", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
else
nSelected = ComboBox.GetSelected("ComboBox1");
if nSelected ~=-1 then
sDrivePath = ComboBox.GetItemData("ComboBox1", nSelected);
tFiles = File.Find(sDrivePath, sFileSearch, false, true, nil, nil);

if tFiles then
for i,FilesPath in tFiles do
ListBox.AddItem(LB, FilesPath, FilesPath);
end
else
Dialog.Message("SEARCH RESULT", "FILES NOT FOUND");
end

else
Dialog.Message("Notice", "PLEASE SELECT A DRIVE", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end
end


When a user launches the program - there is a file name input field, a select a drive dialog field, a Button and a section for the data to show- Image below:

http://www.globalpresentations.net/filesearch.jpg

When a user types in the file name field the code does not search for anything close - it must be an exact match in addition - I would like to specify a drive rather then having someone see all the drives on the computer - also would like to be able to see the sub folders in the folders that are visible


I know this is alot here - any one have any Idea's

Best Regardas,

John

John Fletcher
08-20-2007, 03:02 PM
Did I place this request in the wrong section?

Please advise-----

Best Regards,

John Fletcher:huh

Desrat
08-21-2007, 06:23 AM
so the first thing is that you want to do a wildcard search i.e look for files containing the specified text? rather than an exact match.

second was to specify a drive rather than give a choice

and 3rd was to see the subfolders etc.

I put together a little example that is attached below that covers all 3 hope it helps you figure out what you need..

sermak
03-14-2008, 04:48 PM
Desrat, you give me to permisson to change anything in your apz?