Jump to content

$CmdLine


Recommended Posts

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?

Link to comment
Share on other sites

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 by Buey
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...