check for a CD
    FlexibleLearning at aol.com 
    FlexibleLearning at aol.com
       
    Fri Jan 25 08:16:04 EST 2008
    
    
  
Well done Derek!
I can confirm it works on VISTA. Looks very similar  to the shell solution by 
Ken back in Dec 2004 'GetCDName'. Using shell is not a  fast solution (takes 
about 0.27 seconds per drive and 1.27 for drive A:). A  built-in Rev solution 
may not be very much quicker, however, and depend on what  'instant feedback' 
calls the engine can make to the OS. I mention speed only  because I need this 
on-the-fly within a mouseMove handler to verify text-based  hyperLinks; not 
an issue for a one-off test in other situations, of  course.
/H
My solution to the same problem is to check for a volume serial  number 
first, then if there is one, check for the file I'm looking  for.  You 
can do this with the following function...
function  GetVolumeSN pDiskLetter
local volumeSerialNumber
-- Supports both "C", "C:" and "C:\" styles
put char 1 of  pDiskLetter & ":" into pDisk
set the hideConsoleWindows to  true
put shell("dir " & pDisk) into tDirData
return matchText(tDirData,"Volume Serial Number is 
(.*)\n",volumeSerialNumber) =  "TRUE"
# get matchText(tDirData,"Volume Serial Number is  (.*)\n",volumeSerialNumber)
   # if it is true then
#  return  volumeSerialNumber
# else
#  return  empty
# end if
end GetVolumeSN
If the function returns  a Serial Number, I know a disk is located at 
that drive letter.  I then  do my "if there is a file..." stuff.  If the 
function returns nothing  (empty) then I know there is no disk in the 
drive and I don't check  it.
This seems to avoid the whole "no disc" error in Windows XP  SP2.  I 
don't know about other versions... you'll have to test it  out.
I hope that helps!
   
    
    
More information about the use-livecode
mailing list