Easy cross platform way to show a file?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
tetsuo29
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 50
Joined: Thu Jun 07, 2007 1:30 am

Easy cross platform way to show a file?

Post by tetsuo29 » Wed Apr 16, 2014 11:12 pm

Hi all,

Code: Select all

launch document PathToAFolder
... is an easy way to open the folder containing a file in the Finder/Explorer/Linux Desktop.

However, am I missing something obvious? Is there a way to highlight a particular file that is simple and cross platform? (I saw one solution that involved AppleScript, obviously this will only work on the Mac.)

Thanks in advance for any help.

andrewferguson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 180
Joined: Wed Apr 10, 2013 5:09 pm

Re: Easy cross platform way to show a file?

Post by andrewferguson » Thu Apr 17, 2014 3:44 pm

tetsuo29 wrote:... is an easy way to open the folder containing a file in the Finder/Explorer/Linux Desktop.
From looking at the LiveCode documentation, I believe that the "launch document" command launches the document in the default application, not the Finder/Explorer/Linux Desktop. Is this what you are looking for?

Andrew

tetsuo29
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 50
Joined: Thu Jun 07, 2007 1:30 am

Re: Easy cross platform way to show a file?

Post by tetsuo29 » Thu Apr 17, 2014 5:50 pm

Hi Andrew,

Thanks for responding. You're correct if the path given to launch document is the path to a file it will open the document with the default application. However, if the path given is the path to a folder, then the Finder/Explorer/Linux Desktop will open a window to that folder. That's what I meant by "launch document PathToAFolder."

However, it just opens that folder and does not highlight any particular file within that folder. It would be nice to be able to do what "Show in Finder" does in Safari or "Open containing folder" does in Firefox. They not only open the folder containing a particular file they also highlight that file so that if there are many files in the folder, the user does not have to go hunting for it themselves.

It'd be awesome to have a command like "highlight file PathToAFile" or "navigateToFile PathToAFile" that would not only open the containing folder but highlight the targeted file for the user and to do it on Mac, Windows, & Linux.

I googled for this and found some old runrev listserv discussions about using AppleScript to make it happen on the Mac. I have not seen any methods for making it happen on Windows or Linux.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Easy cross platform way to show a file?

Post by Simon » Thu Apr 17, 2014 11:06 pm

Must you use Finder/Explorer?
If not then just make a field and
put the files into fld 1
set the foregroundColor of word 2 of fld 1 to red

Play around with that see if you can get whay you want.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

tetsuo29
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 50
Joined: Thu Jun 07, 2007 1:30 am

Re: Easy cross platform way to show a file?

Post by tetsuo29 » Fri Apr 18, 2014 4:07 am

Hi Simon,

Yes, it's very important to use the Finder/Explorer/[Whatever the equivalent is in Linux]. I don't want to develop my own file browser I want to allow the user to press a button in the interface and be take to the file in whatever native desktop they are using.

The good news is, that I found an AppleScript to do it on the Mac and I was able to develop a VBSCript to do it in Windows. I've 2 out of 3 desired OSes working. So, now the challenge is- can it be done in Linux?

Klaus
Posts: 11009
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Easy cross platform way to show a file?

Post by Klaus » Fri Apr 18, 2014 1:37 pm

Hi Tetsuo,

you can also use a shell command on Windows, take a look here:
http://www.daube.ch/share/win03.html

No idea about Linux, sorry.


Best

Klaus

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 625
Joined: Wed Nov 22, 2006 3:42 pm
Location: France
Contact:

Re: Easy cross platform way to show a file?

Post by Thierry » Fri Apr 18, 2014 1:53 pm

Klaus wrote:Hi Tetsuo,

you can also use a shell command on Windows, take a look here:
http://www.daube.ch/share/win03.html

No idea about Linux, sorry.
Hallo Klaus,

Shell comes from Unix, then linux, then... :)

Regards,

Thierry
Thierry Douez - https://sunny-tdz.com
Pourquoi tant de notes lorsqu'il suffit de jouer les plus belles... [Barbara]

Klaus
Posts: 11009
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Easy cross platform way to show a file?

Post by Klaus » Fri Apr 18, 2014 1:57 pm

Bonjour mon ami,

sure, but I highly doubt we will find a "Explorer.exe" on *NIX! :D


Best

Klaus

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 625
Joined: Wed Nov 22, 2006 3:42 pm
Location: France
Contact:

Re: Easy cross platform way to show a file?

Post by Thierry » Fri Apr 18, 2014 2:04 pm

Klaus wrote:Bonjour mon ami,
sure, but I highly doubt we will find a "Explorer.exe" on *NIX! :D
Are you so sure there is not an open source project for this? 8)
Regards,

Thierry
Thierry Douez - https://sunny-tdz.com
Pourquoi tant de notes lorsqu'il suffit de jouer les plus belles... [Barbara]

Klaus
Posts: 11009
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Easy cross platform way to show a file?

Post by Klaus » Fri Apr 18, 2014 2:18 pm

Thierry wrote:
Klaus wrote:Bonjour mon ami,
sure, but I highly doubt we will find a "Explorer.exe" on *NIX! :D
Are you so sure there is not an open source project for this? 8)
Regards,
Thierry
Now that you say it. There are a LOT of people doing stupid things, so this is definitively possible!
OMG, what a horrible thought! :D

SparkOut
Posts: 1943
Joined: Sun Sep 23, 2007 4:58 pm

Re: Easy cross platform way to show a file?

Post by SparkOut » Fri Apr 18, 2014 2:33 pm

for generic working with various distros:

xdg-open "path to file" will open the file in the default application.
xdg-open "path to folder" will open the containing folder in the default file manager with no selection

On my server at least (Mepis) dolphin has a --select argument so:

dolphin --select "path to file" will open the containing folder in dolphin with the file selected. Maybe other file managers will have a similar option?

Post Reply

Return to “Talking LiveCode”