file dragged to icon

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
keyless
Posts: 211
Joined: Wed Dec 12, 2007 11:21 pm

file dragged to icon

Post by keyless » Sun Sep 14, 2008 11:23 pm

Was wondering if this is possible with Rev. Making a standalone app that could be activated by dragging a file to its exe icon.

Example: A file zip program, that all you have to do is drag files to it's icon on the desktop, and the program launches and produces the Zip file.

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Mon Sep 15, 2008 6:42 am

That is certainly possible. On MacOSX, you'll need to trap the 'appleEvent' message, and on Windows you script your 'startup' handler to look at the command-line parameters '$1', '$2, '$3', etc.
Also nice is that you can then leave the applicatin open and provide a drag-and-drop area in your stack where people can drag files and folders into and achieve the same effect as when dropping onto the icon, possibly with a UI for advanced settings.
Continuing along that path - on Windows, if you want to prevent the application from being opened multiple times, you should also tale a look at the entry for the 'relaunch' message in the Rev dictionary.

Hope this helped,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

keyless
Posts: 211
Joined: Wed Dec 12, 2007 11:21 pm

Post by keyless » Tue Sep 16, 2008 4:31 am

Janschenkel wrote:That is certainly possible. On MacOSX, you'll need to trap the 'appleEvent' message, and on Windows you script your 'startup' handler to look at the command-line parameters '$1', '$2, '$3', etc.
Also nice is that you can then leave the applicatin open and provide a drag-and-drop area in your stack where people can drag files and folders into and achieve the same effect as when dropping onto the icon, possibly with a UI for advanced settings.
Continuing along that path - on Windows, if you want to prevent the application from being opened multiple times, you should also tale a look at the entry for the 'relaunch' message in the Rev dictionary.

Hope this helped,

Jan Schenkel.
Thanks Jan, I was aware of the command line parameters, but did not know they would pass files dropped on an icon (and definitly not worded as such in rev documentation. )

I'm familier with the other things you mention and have used them with great success.

Thanks again for your ever helpful answers.

One quick question, Is there a way to tell how many parameters there are (ex $1, $2,.....) or should I just check from one until i find a blank one?

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Tue Sep 16, 2008 5:06 am

That would be '$#' - though I'm not quite sure when that was added.

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

keyless
Posts: 211
Joined: Wed Dec 12, 2007 11:21 pm

Post by keyless » Tue Sep 16, 2008 6:21 am

Janschenkel wrote:That would be '$#' - though I'm not quite sure when that was added.

Jan Schenkel.
It was added in 2.9 :cry: I'm using 2.8.1

I wrote this quick, and it works, but I'm sure someone has something more elegant and without the 999 limit.

Code: Select all

 repeat with i = 1 to 999 
    put value("$" & i) into Fchecker
    if Fchecker is empty then exit repeat
    put Fchecker & cr after theDropped
  end repeat

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10049
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Post by FourthWorld » Tue Sep 16, 2008 5:03 pm

This discussion describes how to handle the dropped file well, but hasn't yet described how the OS knows to let the application handle the drop.

On OS X, this is handled in the plist file in the bundle, normally written appropriately by Rev's standalone builder. If details are needed that's described in depth here:
http://sonsothunder.com/devres/revoluti ... ile005.htm

On Windows, a registry entry is required. Commonly this is done by an installer (Wise Install makes this simple), but it's possible to have your Rev app do this itself on launch - details for this also at Ken Ray's site:
http://sonsothunder.com/devres/revoluti ... ile004.htm
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

matthiasr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 195
Joined: Sat Apr 08, 2006 7:55 am
Contact:

Post by matthiasr » Tue Sep 16, 2008 6:56 pm

One little thing to be aware in windows with commandlines:

Under windows there are only 9 standalone commandline paramters possible ($1 - $9).

I don't knw how much are supported under OS X or Linux. But under Windows there are only 9.

see also my bugreport at
http://quality.runrev.com/qacenter/show_bug.cgi?id=7148

This behaviour is already confirmed by Runrev and will be corrected in the next version.

Regards,

Matthias

keyless
Posts: 211
Joined: Wed Dec 12, 2007 11:21 pm

Post by keyless » Wed Sep 17, 2008 2:31 am

matthiasr wrote:One little thing to be aware in windows with commandlines:

Under windows there are only 9 standalone commandline paramters possible ($1 - $9).

I don't knw how much are supported under OS X or Linux. But under Windows there are only 9.

see also my bugreport at
http://quality.runrev.com/qacenter/show_bug.cgi?id=7148

This behaviour is already confirmed by Runrev and will be corrected in the next version.

Thanks for the heads up. Yes, I tested my file drop and it does only allow for 9 files.

Regards,

Matthias

keyless
Posts: 211
Joined: Wed Dec 12, 2007 11:21 pm

Post by keyless » Wed Sep 17, 2008 2:32 am

matthiasr wrote:One little thing to be aware in windows with commandlines:

Under windows there are only 9 standalone commandline paramters possible ($1 - $9).

I don't knw how much are supported under OS X or Linux. But under Windows there are only 9.

see also my bugreport at
http://quality.runrev.com/qacenter/show_bug.cgi?id=7148

This behaviour is already confirmed by Runrev and will be corrected in the next version.

Regards,

Matthias
Thanks for the heads up. Yes, I tested my file drop and it does only allow for 9 files. Any temp workaround?

matthiasr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 195
Joined: Sat Apr 08, 2006 7:55 am
Contact:

Post by matthiasr » Wed Sep 17, 2008 8:30 pm

If you want to drag files onto a shortcut under windows, then there is no workaround. I am sorry.

See the answer to my bugreport of Mark Waddingham at
http://quality.runrev.com/qacenter/show_bug.cgi?id=7148

It seems, we have to wait for the next version.

Regards,

Matthias

Post Reply