Jump to content

$CmdLine[0] Crash


Go to solution Solved by TripleBook,

Recommended Posts

Posted

I am trying to pass 2 switches for the program to run else it will terminate.  Everything runs fine until it starts to add my includes.  I get an error of "array variable has incorrect number of subscripts"

Thanks for any pointers.

;this works
 If $CmdLine[0] = 1 Then MsgBox(0, "", "scripts written by ." & @CRLF & "Phone: ") Exit
 If $CmdLine[0] = 0 Then MsgBox(0, "", "scripts written by ." & @CRLF & "Phone: ") Exit
 If $CmdLine[1] = "blahswitch" Then
 If $CmdLine[2] <> "431128" Then Exit
else
 MsgBox(0,"","nope")
 Exit
 EndIf
 
MsgBox(0,"","Madeit")
 
;this doesn't
#include <String.au3>
#include <INet.au3>
#include <Zip.au3>
#include <File.au3>
#include <Array.au3>
#RequireAdmin
Break(0)
Posted

I don't get the comment on the first line of the script, this script doesn't run at all as written, with or without the includes, because you wrote the If statements wrong. Try this.

;this works
If $CmdLine[0] < 2 Then Exit(MsgBox(0, "", "scripts written by ." & @CRLF & "Phone: "))
If $CmdLine[1] = "blahswitch" Then
    If $CmdLine[2] <> "431128" Then Exit
Else
    MsgBox(0, "", "nope")
    Exit
EndIf

MsgBox(0, "", "Madeit")

;this doesn't
#include <String.au3>
#include <INet.au3>
#include <Zip.au3>
#include <File.au3>
#include <Array.au3>
#RequireAdmin
;~ Break(0) ; <<<<<<<<<<<<<<<<<<<<< Do you know what this does? Why bother using it?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

  Reveal hidden contents

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted (edited)

It was working without the includes.

I think you simplified the code.

Break(0) , Prevents people from stopping the script once it has been started.

 

I tried the simplified code with the same results . 

Edited by TripleBook
Posted

  Quote

 

I get an error of "array variable has incorrect number of subscripts"

 

I'm assuming you have Scite editor.. What is the infomation relating to the error?

example...

C:AutoItScript.au3(15,26) : ERROR: syntax error

    MsgBox(0, "", "nope")ThisCreatesError

~~~~~~~~~~~~~~~~~~~^

C:AutoItScript.au3 - 1 error(s), 0 warning(s)

 

Posted

I do not know how to use the editor to use F5 and add command line arguments.  I have been compiling and running it as someexe.exe switch1 switch2. 

When I compiled it with no includes it would make it to each testing msgbox.  When I add the includes it will run to each testing point until it hits the includes.

I tried taking away each of the includes one at a time.  It still would not work.  So I can either have the command line arguments or have the includes but not both.

Posted
  On 8/24/2013 at 3:33 PM, Jos said:

SciTE: Shift+F8 or View/Parameters to add commandline parameter for F5.

Jos

I was just about to say something similar. I'm glad this forum has that 'reply added' popup :) I was at another forum this morning, and by the time I would post my reply, there would be 3 or 4 other replies.. all saying pretty much the same thing.

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Posted (edited)

After using the shift F8 to add parameters I got this .

:Program Files (x86)AutoIt3IncludeZip.au3 (456) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$ZipFile = $ZipSplit[2]
$ZipFile = ^ ERROR

After commenting out the Zip include it ran all the way with no issue.  Thanks so much for your help.

 I opened up the ZIp include and I see that it accepts cmd line parameters. 

Is there a way to parse the cmd parameters after they are no longer needed.?

Below is what the zip include had.

;
; AutoIt Version: 3.2
; Language:       English
; Description:    ZIP Functions.
; Author:    torels_
;
; ------------------------------------------------------------------------------
If UBound($CMDLine) > 1 Then
 If $CMDLine[1] <> "" Then _Zip_VirtualZipOpen()
EndIf
Edited by TripleBook
  • Solution
Posted

I had never used the Virtual Zip Open feature so I just commented it out and all is working. 

 

This was my first time ever asking for help on the forum.  Thanks to all that helped.

 

If UBound($CMDLine) > 1 Then
 ;If $CMDLine[1] <> "" Then _Zip_VirtualZipOpen()
EndIf
 

 

 

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
  • Recently Browsing   0 members

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