Sign in to follow this  
Followers 0
Damastah

$CmdLine[] error

4 posts in this topic

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?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

If $cmdline[0] > 0 then

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

If $CmdLine[0] > 0 Then
For $X = 1 to $CmdLine[0]
ConsoleWrite("["&$X&"]: " & $CmdLine[$X] & @CRLF)
Next
Else
ConsoleWrite("No command line arguments passed" & @CRLF)
EndIf

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0