UnderwareDESIGN

PlayBASIC => Resources => Source Codes => Topic started by: kevin on August 26, 2010, 01:05:25 AM

Title: Check If Device Is Writable
Post by: kevin on August 26, 2010, 01:05:25 AM
 Check If Device Is Writable

    This function checks if a device is writable or not.  


[pbcode]
for lp=asc("A") to asc("F")
   print CheckDeviceIsWritable(chr$(lp)+":")
next
Sync
waitkey


Function CheckDeviceIsWritable(Device$)
   device$=getdevicename$(device$)
   if driveexist(device$)
      repeat
         RandomString$=""
         for lp=0 to 24
            RandomString$+= chr$(asc("a")+rnd(25))
         next
         RandomString$+=".txt"
         File$=Device$+RandomString$
      until fileexist(file$)=false
   
      Handle=writenewfile(file$)
      if Handle
         CloseFile Handle

         if Fileexist(file$)=true
            Status=true
            deletefile file$
         endif

      endif   
   endif
EndFunction Status



[/pbcode]