How to do a search for a directory or file runing on Windows
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
How to do a search for a directory or file runing on Windows
Dear Friends.
i am not sure how to go about this as i have search the forum but did not find any examples.
Basically, the users keys in the date in this format YYYY-MM-DD and the stack will search in a particular path pre-defined in the search button. the pre-define directory will be \\10.2.260.2\messages\
In the message folders there will be many folders with the date as pre the above date format. The search stack should display to the user that particular folder. The user will then click on that folder and read the content which fill have many text files in it.
Could the LIVEcode friends help.
Thank You
Subas
i am not sure how to go about this as i have search the forum but did not find any examples.
Basically, the users keys in the date in this format YYYY-MM-DD and the stack will search in a particular path pre-defined in the search button. the pre-define directory will be \\10.2.260.2\messages\
In the message folders there will be many folders with the date as pre the above date format. The search stack should display to the user that particular folder. The user will then click on that folder and read the content which fill have many text files in it.
Could the LIVEcode friends help.
Thank You
Subas
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Location: Aalst, Belgium
- Contact:
Re: How to do a search for a directory or file runing on Win
Hi Subas,
You can set the 'defaultFolder' global property to the actual directory where the files are, and then use the 'files' function to get a list of the files this directory contains. Then you can read each of those files individually and apply your search algorithm.
HTH,
Jan Schenkel.
You can set the 'defaultFolder' global property to the actual directory where the files are, and then use the 'files' function to get a list of the files this directory contains. Then you can read each of those files individually and apply your search algorithm.
HTH,
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
Re: How to do a search for a directory or file runing on Win
Dear Jan,
Thanks for the information.
Actually the search of the directory is what i need. Example: the users keys in on the 1st text field <ddmmyy> and a 2nd field the user keys in <AF001>. The system will start the search and goes to the initial default path \\10.2.260.2\messages\ and then look for the folder called <ddmmyy> in the message folder. Once the system finds it it will then take the 2nd field which is <AF001> that the users had keyed in an then display the files in that directory folder.
Could you please help on how to do this.
Thanks
Best Regards
Subas
Thanks for the information.
Actually the search of the directory is what i need. Example: the users keys in on the 1st text field <ddmmyy> and a 2nd field the user keys in <AF001>. The system will start the search and goes to the initial default path \\10.2.260.2\messages\ and then look for the folder called <ddmmyy> in the message folder. Once the system finds it it will then take the 2nd field which is <AF001> that the users had keyed in an then display the files in that directory folder.
Could you please help on how to do this.
Thanks
Best Regards
Subas
Re: How to do a search for a directory or file runing on Win
Code: Select all
set the defaultFolder to ("\\10.2.260.2\messages\" + the text of field "firstField" + "\" + the text of field "secondField")
set the text of field "listOfFiles" to (the files)
Re: How to do a search for a directory or file runing on Win
Dear shaosean
After trying the code out I get the below error:-
button "Button": execution error at line 2 (Operators +: error in left operand), char 30
could you help please.
Thanks
After trying the code out I get the below error:-
button "Button": execution error at line 2 (Operators +: error in left operand), char 30
could you help please.
Thanks
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Location: Aalst, Belgium
- Contact:
Re: How to do a search for a directory or file runing on Win
I guess Shao Sean got some languages mixed up LiveCode uses an ampersand to concatenate strings.
HTH,
Jan Schenkel.
Code: Select all
set the defaultFolder to ("\\10.2.260.2\messages\" & the text of field "firstField" & "\" & the text of field "secondField")
set the text of field "listOfFiles" to (the files)
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
Re: How to do a search for a directory or file runing on Win
yeah, using more than one language i sometimes get things mixed up
Re: How to do a search for a directory or file runing on Win
dear Janschenkel and shaosean
the code work perfectly. thank you
just one question can live code read the names of directories and pass those name to a drop down list so the user can select the appropriate directory? Also if there are changes made on the directory the system can then notify the user that there was a new directory?
Thanks
Best Regards
Subas
the code work perfectly. thank you
just one question can live code read the names of directories and pass those name to a drop down list so the user can select the appropriate directory? Also if there are changes made on the directory the system can then notify the user that there was a new directory?
Thanks
Best Regards
Subas
Re: How to do a search for a directory or file runing on Win
that's actually two questions
instead of "the files" use "the folders".. the engine does not support the file system change notifications, but (could you see this coming? ) you could always write an external to do it..
instead of "the files" use "the folders".. the engine does not support the file system change notifications, but (could you see this coming? ) you could always write an external to do it..
Re: How to do a search for a directory or file runing on Win
Dear shaosean.
Thank you I will try this out tonight. have a nice day ahead.
Best Regards
Subas
Thank you I will try this out tonight. have a nice day ahead.
Best Regards
Subas
Re: How to do a search for a directory or file runing on Win
Hi Subas,
Hint:
Livecode uses the UNIX pathdelimiter SLASH / internally, sou you should use them in your pathnames, EVEN if this is currently working
...
set the Folder to ("//10.2.260.2/messages/" & the text of field "firstField" & "/" & the text of field "secondField")
...
By the way, does this really work:
...
set the Folder to "//10.2.260.2/messages/"
...
?
And not to forget my eternal hint to this wonderful learning resource:
http://www.hyperactivesw.com/revscriptc ... ences.html
Best
Klaus
no need for this, you can dynamically fill that button "on mousedown" or "on mouseenter", so it is always up-to-dateSubas wrote: Also if there are changes made on the directory the system can then notify the user that there was a new directory?
Hint:
Livecode uses the UNIX pathdelimiter SLASH / internally, sou you should use them in your pathnames, EVEN if this is currently working
...
set the Folder to ("//10.2.260.2/messages/" & the text of field "firstField" & "/" & the text of field "secondField")
...
By the way, does this really work:
...
set the Folder to "//10.2.260.2/messages/"
...
?
And not to forget my eternal hint to this wonderful learning resource:
http://www.hyperactivesw.com/revscriptc ... ences.html
Best
Klaus
Re: How to do a search for a directory or file runing on Win
Hi Klaus.
Good to hear from you. About your question of it the ip path actually works, yes it does seem to work. I am on a vpn access and the only folder on that server is the message folder. I was able to get to that folder and display the necessary directories. Since you mention it I will re check this on Monday morning fully.
Also thanks for the hint on the Unix path. I will change it based on that as I have seen most example showing it that way.
Also could you point me to the right direction for the "you can dynamically fill that button "on mousedown" or "on mouseenter", so it is always up-to-date" procedures. This is what I actually have in mind.
Thanks for the help and good to hear from you again.
Best Regards
Subas
Good to hear from you. About your question of it the ip path actually works, yes it does seem to work. I am on a vpn access and the only folder on that server is the message folder. I was able to get to that folder and display the necessary directories. Since you mention it I will re check this on Monday morning fully.
Also thanks for the hint on the Unix path. I will change it based on that as I have seen most example showing it that way.
Also could you point me to the right direction for the "you can dynamically fill that button "on mousedown" or "on mouseenter", so it is always up-to-date" procedures. This is what I actually have in mind.
Thanks for the help and good to hear from you again.
Best Regards
Subas
Re: How to do a search for a directory or file runing on Win
Hi Friends
Can some please help. I am not getting all my files shown on Field 3 below.
Can some please help. I am not getting all my files shown on Field 3 below.
Code: Select all
on mouseUp
put empty into button "Option Menu1" -- Clear everything on Option Menu 1
set the defaultFolder to ("C:\Users\main\Desktop\live\" & the text of field "Field1" & "\" & the text of field "Field2") --Users keys in the 1st and 2nd Folder
put the folders into theNewList --System reads the files in the 2nd Folder
repeat with count = 1 to the number of items of theNewList
put item count of theNewList & cr after button "Option Menu1" --i get my folders dispalyed on the drop down list. User select from The Option Menu 1
set "Option Menu1" of field "Field3" to (the files) --when user select the folder from Option Menu1 the files should display on Field3
end repeat
end mouseUp
Re: How to do a search for a directory or file runing on Win
Code: Select all
on mouseUp
put empty into button "Option Menu1" -- Clear everything on Option Menu 1
set the defaultFolder to ("C:\Users\main\Desktop\live\" & the text of field "Field1" & "\" & the text of field "Field2") --Users keys in the 1st and 2nd Folder
put the folders into theNewList --System reads the files in the 2nd Folder
-- this is where the issues are
repeat with count = 1 to the number of items of theNewList
put item count of theNewList & cr after button "Option Menu1" --i get my folders dispalyed on the drop down list. User select from The Option Menu 1
set "Option Menu1" of field "Field3" to (the files) --when user select the folder from Option Menu1 the files should display on Field3
end repeat
end mouseUp
Code: Select all
put the folders into theNewList --System reads the files in the 2nd Folder
This code is in a button somewhere, or perhaps a use a different handler
Code: Select all
on mouseUp
set the defaultFolder to ("C:\Users\main\Desktop\live\" & the text of field "Field1" & "\" & the text of field "Field2") --Users keys in the 1st and 2nd Folder
set the text of button "Option Menu1" to (the folders)
end mouseUp
Code: Select all
on menuPick pChosenItem
set the defaultFolder to (the defaultFolder & SLASH & pChosenItem)
set the text of field "Field3" to (the files)
end menuPick
Re: How to do a search for a directory or file runing on Win
Hi Subas,
as Mark said
Hints:
1. "the files" and "the folders" return a CR delimited list, so this is not very clever:
...
put the folders into theNewList --System reads the files in the 2nd Folder
repeat with count = 1 to the number of items of theNewList
...
There is only ONE item (itemdelimiter is COMMA by default) in theNewList!
It would be a good idea to take a look at the terms in the dictionary if in doubt or if you get unexspected results!
I still do this after almost 15 years of working with Livecode, this is not a shame!
2. About dynamcially filling the button with folder content.
I would create a little function in the stackscript, that will return the files or the folders from a give folder,
so I can use this everwhere I need it like this:
Now you can add this to the script of your "option" button:
Et voila, all available folders in menu, dynamically and up-to-data as possible
Best
Klaus
as Mark said
Hints:
1. "the files" and "the folders" return a CR delimited list, so this is not very clever:
...
put the folders into theNewList --System reads the files in the 2nd Folder
repeat with count = 1 to the number of items of theNewList
...
There is only ONE item (itemdelimiter is COMMA by default) in theNewList!
It would be a good idea to take a look at the terms in the dictionary if in doubt or if you get unexspected results!
I still do this after almost 15 years of working with Livecode, this is not a shame!
2. About dynamcially filling the button with folder content.
I would create a little function in the stackscript, that will return the files or the folders from a give folder,
so I can use this everwhere I need it like this:
Code: Select all
## 2 parameters:
## 1. the folder from where you want to get the content from
## 2. to make it a bit more useful we can supply "files" or "folders" as the second parameter
## so we can have the files OR the folders with the same function!
function GetFolderContent tFolder,FilesOrFolders
## Note previous directory and RESET this at the end!
## This is good programming style ;-)
put the folder into tOldDir
set the folder to tFolder
if FilesOrFolders = "files" then
put the files into tretValue
else
put the folders into tRetValue
end if
## Reset directory!
set the folder to tOldDir
return tRetValue
end GetFolderContent
Code: Select all
on mouseenter
put ("C:/any valid folder path/here/" & the text of field "Field1" & "/" & the text of field "Field2") into tFolder
put GetFolderContent(tFolder,"folders") into me
end mouseenter
Best
Klaus