Volume Mount Message

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
smoke
Posts: 4
Joined: Sat May 07, 2011 4:19 pm

Volume Mount Message

Post by smoke » Sat May 07, 2011 4:22 pm

Is there a way to get a message when a volume is mounted?

Also, a command to unmount a volume?

Thanks!

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Volume Mount Message

Post by jmburnod » Sat May 07, 2011 4:29 pm

Hi Smoke,

Yes,

the volumes() function return the list of volumes (one volume by line)

Best

Jean-Marc
https://alternatic.ch

smoke
Posts: 4
Joined: Sat May 07, 2011 4:19 pm

Re: Volume Mount Message

Post by smoke » Sat May 07, 2011 4:49 pm

Thanks Jean-Marc,

But I would have to run an idle handler to constantly query the volumes to know when a new volume is mounted, no?

I was hoping for a message that could trigger a handler?

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Volume Mount Message

Post by jmburnod » Sat May 07, 2011 5:46 pm

Hi Smoke,
But I would have to run an idle handler to constantly query the volumes to know when a new volume is mounted, no?
Yes. You can do it but maeby someone have a best way

Best

Jean-Marc
https://alternatic.ch

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

Re: Volume Mount Message

Post by FourthWorld » Sat May 07, 2011 8:29 pm

The rate at which idle messages are fired is governed by the idleRate property, so you could use it and minimize overhead by setting it to something higher than the default value of 200.

You may also consider a timer instead - this example uses "send in <time>" to generate a VolumeChanged message:

Code: Select all

local sLastVolumes
on CheckVolumesChanged
  if the volumes <> sLastVolumes then
    dispatch "VolumesChanged" to this cd
  end if
  put the volumes into sLastVolumes
  send "CheckVolumesChanged" to me in 500 millisecs -- or whatever interval you feel is appropriate
end CheckVolumesChanged
You could enhance that to walk through the list to find which volumes have been added or removed and add that as argumens to the VolmesChanges notification it sends.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Volume Mount Message

Post by shaosean » Sun May 08, 2011 3:46 am

You can do this through an external and that would save you from having to poll with the idle command..

smoke
Posts: 4
Joined: Sat May 07, 2011 4:19 pm

Re: Volume Mount Message

Post by smoke » Sun May 08, 2011 2:48 pm

shaosean wrote:You can do this through an external..
Cool. Where would I find such a beast?

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Volume Mount Message

Post by shaosean » Sun May 08, 2011 8:00 pm

You would either need to write it yourself, or get someone to write it for you..

smoke
Posts: 4
Joined: Sat May 07, 2011 4:19 pm

Re: Volume Mount Message

Post by smoke » Sun May 08, 2011 8:29 pm

I have not written externals for Rev before. Is there an SDK? Some example shells?


Post Reply