Jump to content

$CmdLine[] error


Recommended Posts

In my script i have a line which goes a little something like this.

$opt = $CmdLine[1]
msgbox(0, "", $opt)

I get the error: "Array variable has incorrect number of subscripts or subscript dimention range exceeded." this is only like my third line of code and I put in the command line when i ran it,

C:\scripts\whatever.au3 1

It tells me that the error is the $cmdLine [1] part.

this is what it looks like:

...

$opt = $CmdLine [1]

$opt = ^ ERROR

Error: Array variable has incorrect number of subscripts or subscript dimention range exceeded.

What's wrong?
Link to comment
Share on other sites

  • Developers

Add a test to ensure that the $cmdline array contains it.

If $cmdline[0] > 0 then

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • 2 weeks later...

In my script i have a line which goes a little something like this.

$opt = $CmdLine[1]
msgbox(0, "", $opt)

I get the error: "Array variable has incorrect number of subscripts or subscript dimention range exceeded." this is only like my third line of code and I put in the command line when i ran it,

It tells me that the error is the $cmdLine [1] part.

What's wrong?

In addition to what Jos and weaponx wrote, you need to make sure that if you're calling your script as an .au3 file (as opposed to a compiled .exe) then you need to call it like this:

"C:\Program Files\AutoIT\AutoIT3.exe" myscript.au3 1

For testing purposes, within SciTE you can hit Shift+F8 to show the Parameters box. Any values you put in any of these boxes will emulate passing parameters from a command line or shortcut.

Edited by Jeemo

An emoticon is worth a dozen words.

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...