giogio Posted December 28, 2007 Share Posted December 28, 2007 func FindRemovableDisk() ; THIS DOESN'T WORK************************************* $label =$CmdLine[2] MsgBox(4096, "", $label) if $label="" then ; if command line not present exit ;*****EXIT***** Sleep(10) Exit 200 EndIf ;******************************************* $var = DriveGetDrive("REMOVABLE") $FlagFunc="ok" If Not @error then ;MsgBox(4096, "", "Found " & $var[0] & " drives") For $i = 1 To $var[0] If DriveGetLabel($var[$i]) = $label Then ConsoleWrite ($var[$i]); no error ;*****EXIT***** Sleep(10) Exit 200 EndIf Next EndIf consoleWrite ("@error") ; error EndFunc PEASE HELP ME Link to comment Share on other sites More sharing options...
DW1 Posted December 28, 2007 Share Posted December 28, 2007 where are you defining $CmdLine[2]? AutoIt3 Online Help Link to comment Share on other sites More sharing options...
weaponx Posted December 28, 2007 Share Posted December 28, 2007 where are you defining $CmdLine[2]? When the program is called with parameters from the command line? Link to comment Share on other sites More sharing options...
DW1 Posted December 28, 2007 Share Posted December 28, 2007 @weaponX, how do I define that in the script? AutoIt3 Online Help Link to comment Share on other sites More sharing options...
giogio Posted December 28, 2007 Author Share Posted December 28, 2007 FROM THE CMD.EXE I RUN C:\MYSCRIPT.EXE "MYPARAMETER" IF I FORGOT THE PARAMENTER I GET THIS AUTOIT ERROR: LINE-1: ERROR: ARRAY VARIABLE HAS INCORRECT NUMBER OF SUBSRIPTS OR SUBSCRIPT DIMENSION RANGE EXCEEDED. Link to comment Share on other sites More sharing options...
weaponx Posted December 28, 2007 Share Posted December 28, 2007 You don't define it, it is a constant. There has been many questions about why it isn't @CmdLine, but I think its because its an array. $CmdLine[0] Contains the number of parameters passed to your script $CmdLine[1] Contains parameter 1 $CmdLine[2] Contains parameter 2 This is explained in the Help file under Using Autoit > Command Line Parameters Link to comment Share on other sites More sharing options...
DW1 Posted December 28, 2007 Share Posted December 28, 2007 Your script is waiting for the second parameter though. If you want to run "C:\MYSCRIPT.EXE "MYPARAMETER"" , you need to change $CmdLine[2] to $CmdLine[1]. $CmdLine[0] hold how many parameters the script was called with. AutoIt3 Online Help Link to comment Share on other sites More sharing options...
weaponx Posted December 28, 2007 Share Posted December 28, 2007 (edited) Func FindRemovableDisk() If $CmdLine[0] = 0 Then Return 0 EndIf $label = $CmdLine[2] MsgBox(4096, "", $label) If $label = "" Then ; if command line not present exit ;*****EXIT***** Sleep(10) Exit 200 EndIf ;******************************************* $var = DriveGetDrive("REMOVABLE") $FlagFunc = "ok" If Not @error Then ;MsgBox(4096, "", "Found " & $var[0] & " drives") For $i = 1 To $var[0] If DriveGetLabel($var[$i]) = $label Then ConsoleWrite($var[$i]); no error ;*****EXIT***** Sleep(10) Exit 200 EndIf Next EndIf ConsoleWrite("@error") ; error EndFunc ;==>FindRemovableDisk Edited December 28, 2007 by weaponx 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