News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

Check If Device Is Writable

Started by kevin, August 26, 2010, 01:05:25 AM

Previous topic - Next topic

kevin

 Check If Device Is Writable

    This function checks if a device is writable or not.  


PlayBASIC Code: [Select]
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