fiodal Posted May 1, 2004 Share Posted May 1, 2004 Can someone help me please... What is the code to check if the CD ROM exists. And if it does, return the value or drive letter? Thanks.. Link to comment Share on other sites More sharing options...
Nutster Posted May 1, 2004 Share Posted May 1, 2004 Try: $x = DriveGetType("CDROM") ;Returns an array with all the CD-Rom's drive letters: if $x[0] >0 Then $cdrom = $x[1] else $cdrom = "" ;None found endif msgbox(0,"Insert Disk", "Please put the CD-Rom in drive " & $cdrom) David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd... Link to comment Share on other sites More sharing options...
fiodal Posted May 1, 2004 Author Share Posted May 1, 2004 Your a great help Thank you Nutster Link to comment Share on other sites More sharing options...
fiodal Posted May 1, 2004 Author Share Posted May 1, 2004 Nutster get an array error.. Where and how do I declare the array? if $x[0] >0 Then if $x^ERROR Error: Subscript used with non-Array variable. Link to comment Share on other sites More sharing options...
scriptkitty Posted May 1, 2004 Share Posted May 1, 2004 (edited) Yea, that isn't the right usage, it doesn't return an array: DriveGetType -------------------------------------------------------------------------------- Returns drive type. DriveGetType ( "path" ) Parameters path Path of drive to receive information from. Return Value Success: Returns the type of drive: "Unknown", "Removable", "Fixed", "Network", "CDROM", "RAMDisk" Failure: Returns numeric 1 and sets @error to 1.so usage would be DriveGetType ( "c:\" ) you can do DriveGetDrive ( "CDROM" ) like: $var = DriveGetDrive( "CDROM" ) If NOT @error Then MsgBox(4096,"", "Found " & $var[0] & " drives") For $i = 1 to $var[0] MsgBox(4096,"Drive " & $i, $var[$i]) Next EndIf just off by a few letters there or: $x = DriveGetDrive("CDROM");Returns an array with all the CD-Rom's drive letters: if $x[0] >0 Then $cdrom = $x[1] else $cdrom = "";None found endif msgbox(0,"Insert Disk", "Please put the CD-Rom in drive " & $cdrom) Edited May 1, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
herworth Posted May 1, 2004 Share Posted May 1, 2004 I'm a very simple guy and I use this function #include - once local $CDDrive Func FindCD() $CDDrive = "" for $x = 68 to 71 if fileexists(Chr($x) & ":\") then $CDDrive = Chr($x) & ":\" exitloop endif next Return $CDDrive EndFunc It works fine every time for me. [u][font="Arial"]Pete[/font][/u] Link to comment Share on other sites More sharing options...
Valik Posted May 1, 2004 Share Posted May 1, 2004 One note, declaring something as Local outside the scope of a function doesn't make it local to the function, it makes it global (Local to global scope is still global to everything else is one way to rationalize that out). Link to comment Share on other sites More sharing options...
Nutster Posted May 3, 2004 Share Posted May 3, 2004 Yea, that isn't the right usage, it doesn't return an array: just off by a few letters there or: $x = DriveGetDrive("CDROM");Returns an array with all the CD-Rom's drive letters: if $x[0] >0 Then $cdrom = $x[1] else $cdrom = "";None found endif msgbox(0,"Insert Disk", "Please put the CD-Rom in drive " & $cdrom)Oops, wrong function. Sorry. Yeah I meant DriveGetDrive, not DriveGetType. David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now