FAQFAQ   SearchSearch   UsergroupsUsergroups   RegisterRegister   ProfileProfile    Log inLog in   RSS Feed

file & folder browsing

 
Post new topic   Reply to topic    Salling Software Forums Forum Index -> Scripting Salling Clicker for Mac
View previous topic :: View next topic  
Author Message
holder
Newbie


Joined: 29 Dec 2005
Posts: 5
Location: Montreal, Canada

PostPosted: Tue Jan 03, 2006 12:35 am    Post subject: file & folder browsing Reply with quote

I've written a script to browse through files and folders. When you select a file, it asks if you want to open that file.

The script works pretty well; however, I have not been able to get it to be selective about which file extensions it includes in its lists. In the attached script, uncomment the ends of the two script lines to see what I mean.

The other irritant is that when returning from a question dialog about opening a file, whether yes or no, the "back" button has to be hit twice before it does something. I can't figure out why this happens.

Any help will be appreciated.

Henry
Back to top
View user's profile Send private message
mark hunte
Junior Member


Joined: 20 Dec 2005
Posts: 39

PostPosted: Thu Jan 05, 2006 9:22 pm    Post subject: Reply with quote

[code:1]set item_list to name of every item of folder dirPath whose (name extension is "scpt" or class is folder)

set item_list_paths to (every item of folder dirPath) whose (name extension is "scpt" or class is folder)[/code:1]

will list folders and scpt files.
But it will not open the folders for some reason, Im new to SEC scripting so it wiill take me a while to understand the script.

Also the double click back problem is (I Think) working as you told the script to work.
Its going back to each selection you made.
Back to top
View user's profile Send private message
mark hunte
Junior Member


Joined: 20 Dec 2005
Posts: 39

PostPosted: Fri Jan 06, 2006 2:25 am    Post subject: Reply with quote

Ok relised it had a problem if the folder it was trying to open,
did not have any scpt or folders in it.
I put in a count check to count if there are any files or folders before
it trys to get the list.

this seems to work.

Still havent figured how to correct your 'Back' problem.
Also although the script works, while only looking for types.
It does not open into what it see's as an empty folder (no scpt files or folders)

maybe you can go through the logic of the push process.
Back to top
View user's profile Send private message
holder
Newbie


Joined: 29 Dec 2005
Posts: 5
Location: Montreal, Canada

PostPosted: Sun Jan 08, 2006 2:09 pm    Post subject: thanks for the suggestion about counting Reply with quote

Thank you, Mark, for the suggestion about counting the items before using "whose" or "where". I've expanded on that:
[code:1]
if (count of (items of folder dirPath whose kind is "Folder")) = 0
and ((count of (items of folder dirPath whose name extension is file_extension)) = 0) then
set item_list to {}
set item_list_paths to {}
else if (count of (items of folder dirPath whose kind is "Folder")) = 0 then
set item_list to name of every item of folder dirPath whose (name extension is file_extension)
set item_list_paths to (every item of folder dirPath) where name extension is file_extension
else if ((count of (items of folder dirPath whose name extension is file_extension)) = 0) then
set item_list to name of every item of folder dirPath whose kind is "Folder"
set item_list_paths to every item of folder dirPath whose kind is "Folder"
else
set item_list to name of every item of folder dirPath whose (name extension is file_extension or kind is "Folder")
set item_list_paths to (every item of folder dirPath) where name extension is file_extension or kind is "Folder"
end if
[/code:1]

The attached script asks you to specify the file extension you want to look for, from a list of extensions. I still need to add a dialog to allow the user to enter any desired file extension.

Henry

P.S. Check out (and contribute!) to the documentation wiki I've set up for scripting Salling Clicker for Macs, here: http://www.henry.olders.ca/ClickerWiki/
Back to top
View user's profile Send private message
holder
Newbie


Joined: 29 Dec 2005
Posts: 5
Location: Montreal, Canada

PostPosted: Fri Jan 13, 2006 6:34 am    Post subject: Reply with quote

Here's the completed file browser. It allows you to pick a file extension, or enter one, and then displays lists of folders or files with the selected extension.

The source listing is posted here: http://www.henry.olders.ca/ClickerWiki/index.php?title=Scripts_submitted_by_contributors_-_Source_Listings

Henry
Back to top
View user's profile Send private message
mark hunte
Junior Member


Joined: 20 Dec 2005
Posts: 39

PostPosted: Fri Jan 13, 2006 10:07 pm    Post subject: Reply with quote

Hi Henry, You script has come along Nicely.

Now SEC scripts are very new to me. So I am struggling a bit.

I have added a bit of script to yours as a test, it works, but will need a lot more work.

To explain:

if you add the code below to your script.

between the parts of your script as shown here (in Bold)
[b]else
open current_path
[/b]
[code:1]

tell application "TextEdit"
set theWord to "Content"
set the_script_text to text of document 1 as Unicode text
close saving no
end tell
tell application "SEC Helper"
tell current terminal
(push (make new messagebox dialog with properties {title:theWord, textual content:the_script_text}))
end tell
end tell

[/code:1]

[b]
end if
on error errorMsg
tell application "SEC Helper" to show screen message "dialog ok error: " & errorMsg duration 5
beep
end try
end process dialog ok
[/b]

Save and run the script from the mobile.

enter the extension 'txt'
go to a text file
select it
yes to open

The content of the File will pop up on the mobile Screen.

As you will also see.

there are things to fix. Like when click OK nothing Happens.
It seems to be stuck in always wanting to open the file.

But any way I hope you get the idea.

It's So we can read the files remotely.

The script should be able to be expanded to other file types.
we could even use shell scripting to get content.

Hope to hear from you
Mark H
Back to top
View user's profile Send private message
holder
Newbie


Joined: 29 Dec 2005
Posts: 5
Location: Montreal, Canada

PostPosted: Sat Feb 18, 2006 5:44 pm    Post subject: Reply with quote

Hi, Mark!

Nice addition!

I did something similar with a Filemaker Pro application that I wrote; it's a patient database, and I use the clicker script to open the database file with a password entered on the remote, then I enter all or part of a patient's name on the remote; this calls a filemaker script to find those patients, whose names are then displayed as a list on the remote; after selecting the patient I want, I can then look at clinical notes, medications, diagnoses, even a photo, on the remote.

Henry
Back to top
View user's profile Send private message
mark hunte
Junior Member


Joined: 20 Dec 2005
Posts: 39

PostPosted: Sat Feb 18, 2006 7:59 pm    Post subject: Reply with quote

Now that sounds way cool.. I forgot you had your site up and running, must check in there.
Back to top
View user's profile Send private message
kseiferlin
Junior Member


Joined: 05 Jun 2006
Posts: 28

PostPosted: Tue Jun 06, 2006 5:47 pm    Post subject: Can you strip the script to fill list with folders only? Reply with quote

Nice script, unfortunately I am not very experienced with applescript. I would like to fill a list on the bluetooth device with folders only (i.e. NOT looking for files at all), and it would be OK if it does not fill the list recursively. Means that I would be happy to see all folders that are one level below the start folder.

Can this be done? May I ask for help?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Salling Software Forums Forum Index -> Scripting Salling Clicker for Mac All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group