magician13134 Posted September 17, 2007 Share Posted September 17, 2007 Ok, I just saw this in a couple scripts... and it confuses me. Not to much is returned on a forum search, and it's not in the help file. So, as far as I can figure, it returns parameters of program as executed by Windows...? But: How do I use it? Why doesn't it have to be declared? It seems more like one of those terms starting with '@' than '$'... Anyone up to giving me a brief explanation? Visit Magic Soft Inc. for some of my software Link to comment Share on other sites More sharing options...
weaponx Posted September 17, 2007 Share Posted September 17, 2007 $CmdLine[0] Returns number of params $CmdLine[1] 1st param $CmdLine[2] 2nd param Link to comment Share on other sites More sharing options...
Buey Posted September 17, 2007 Share Posted September 17, 2007 (edited) In a DOS prompt, when you type: C:> myprogram.exe 5 2 The 5 and 2 are command line parameters of the program. When your AutoIt script is run, anything passed to it in that fashion will be automatically put into a predefined array $CmdLine, where $CmdLine[0] is the number of arguments that were passed, and $CmdLine[1]... are the actual parameters. So, when running: C:> myautoitprogram.exe hello test $CmdLine[0] = 2 $CmdLine[1] = "hello" $CmdLine[2] = "test" As to why it's not a macro (@), my guess would be because it's an array. I don't think there are any array macros, so it was set as a variable. You can treat it as a ubiquitous macro though, it gets declared and set when the program starts. Edited September 17, 2007 by Buey Link to comment Share on other sites More sharing options...
flyingboz Posted September 17, 2007 Share Posted September 17, 2007 If you need the entire command line, use $cmdlineRaw Note that you will have to properly parse the arguments yourself.... Reading the help file before you post... Not only will it make you look smarter, it will make you smarter. 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