alix123 Posted June 11, 2007 Share Posted June 11, 2007 Hii I am try to provide command line arguments to my script ,however the command line arguments are not a mandatory requiremtns in my scripts , if not provided then scripts executes a default run . But what is happening is for eg if I have defined 4 command line arguments $Cmdline[1],$Cmdline[2],$Cmdline[3],$Cmdline[4] all of these becomes a mandatory parameter to the script if i dont provide any of these scripts doesnt runs it return me an error "Array Variable has incorrect number of subscripts or subscript dimension range exeeded " Any solution for make command line arguments as optional??? Link to comment Share on other sites More sharing options...
The Kandie Man Posted June 11, 2007 Share Posted June 11, 2007 You check to see how large the array is. $Cmdline[0] tells you how many command lines were given. If 0 were given, then $Cmdline[0] is equal to 0. If one was given, then $Cmdline[0] is equal to one and so forth. ;This is pseudo code If $Cmdline[0] > 3 Then $Cmdline[1],$Cmdline[2],$Cmdline[3],$Cmdline[4];whatever you do with those here Endif - The Kandie Man ;-) "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 11, 2007 Share Posted June 11, 2007 Just don't refer the command line parameter without first checking that they are present: If $CmdLine[0] = 4 Then ... Else ; Default values ... EndIf Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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