Jump to content

Switch Error Message


Recommended Posts

Every time I run my script with the switch I get the following error message:

Line -1:

Error: Array variable has incorrect number of subscripts or subscript dimension rage exceeded.

Here is the script:

#include <Misc.au3>
#include<Zip.au3>
#NoTrayIcon
If FileExists("C:\ThinClient") Then
    Exit
    Else
if _Singleton("Refresher",1) = 0 Then
    Msgbox(0,"Warning","An occurence of Lab Refresher is already running.")
    Exit
EndIf
EndIf
DirCreate("C:\HighlandAutomation")
$Server = "\\adm-24-server01\RCData\ComputerAutomation"
$Local = "C:\HighlandAutomation"
;####Close any open version of Controller#####
If ProcessExists("ControlDaemon.exe") Then
    ProcessClose("ControlDaemon.exe")
EndIf
IF ProcessExists("LabDaeamon.exe")Then
    ProcessClose("LabDaeamon.exe")
EndIf
If ProcessExists("Rules.exe")Then
    ProcessClose("Rules.exe")
EndIf
;#####Delete OLD Version Of Controller######
Filedelete($local&"\*.*")
;#####Install Controller Components onto local computer#####
FileInstall("E:\Computer Lab Control Autoit Stuff\Current Version(s)\ComputerAutomation\ControlDaemon.exe", "C:\HighlandAutomation\ControlDaemon.exe", 1)
FileInstall("E:\Computer Lab Control Autoit Stuff\Current Version(s)\ComputerAutomation\Include_Files\splash.bmp", "C:\HighlandAutomation\splash.bmp", 1)
FileInstall("E:\Computer Lab Control Autoit Stuff\Current Version(s)\ComputerAutomation\Include_Files\GTW_blue.bmp", "C:\HighlandAutomation\GTW_blue.bmp", 1)
FileInstall("E:\Computer Lab Control Autoit Stuff\Current Version(s)\ComputerAutomation\Include_Files\Lab Theme.theme", "C:\HighlandAutomation\Lab Theme.theme", 1)
FileInstall("E:\Computer Lab Control Autoit Stuff\Current Version(s)\ComputerAutomation\Include_Files\rules.exe", "C:\HighlandAutomation\rules.exe", 1)
;#####Start Controller Daemon#####

If $cmdline[0] > 0 Then
    Switch $cmdline[1]
        Case "HEARTS", "-h"
            Hearts()
        EndSwitch
    Else
        Lab()
    EndIf
    
Func Lab()
Run($Local&"\ControlDaemon.exe", $Local)
Run($Local&"\Rules.exe", $Local)
If Fileexists ($Local&"\Refresher.exe") Then
FileCreateShortcut($Local&"\Refresher.exe",@StartupDir & "\Refresher.lnk",$Local)
Else 
FileCopy($server&"\Refresher.exe",$Local,1)
FileCreateShortcut($Local&"\Refresher.exe",@StartupDir & "\Refresher.lnk",$Local)
Endif
EndFunc

Func HEARTS()
Run($Local&"\ControlDaemon.exe -h", $Local)
Run($Local&"\Rules.exe -h", $Local)
If Fileexists ($Local&"\Refresher.exe") Then
FileCreateShortcut($Local&"\Refresher.exe -h",@StartupDir & "\Refresher.lnk",$Local)
Else 
FileCopy($server&"\Refresher.exe",$Local,1)
FileCreateShortcut($Local&"\Refresher.exe -h",@StartupDir & "\Refresher.lnk",$Local)
Endif
EndFunc
Link to comment
Share on other sites

Ok, I think I found the issue, AutoIt is case sensitive, so $CmdLine is different than $cmdline.

#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

Link to comment
Share on other sites

Ok, I think I found the issue, AutoIt is case sensitive, so $CmdLine is different than $cmdline.

Well the odd part is if I take the code and type it like below it works.

If $cmdline[0] > 0 Then
    Switch $cmdline[1]
        Case "HEARTS", "-h"
            Hearts()
        EndSwitch
    Else
        Start()
    EndIf
    
Func Hearts()
    MsgBox(0, "test", "HEARTS")
EndFunc

Func Start()
    Msgbox(0, "test", "Start")
    EndFunc
Link to comment
Share on other sites

That is interesting, let me look into it

Update: That's really quite weird, I can't run all of your code on my box, but that little snippet flies through w/o a problem. I wonder why they chose to make that particular variable non-case sensitive. Other than that I'm not sure where the error could be, as that is the only place in your code that uses array subscripts. Sorry I couldn't be more help on this one. Posted Image

The annoy thing thing is that I just know that it's going to be something maddeningly simple.

Edited by Fulano

#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

Link to comment
Share on other sites

whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

That is interesting, let me look into it

Update: That's really quite weird, I can't run all of your code on my box, but that little snippet flies through w/o a problem. I wonder why they chose to make that particular variable non-case sensitive. Other than that I'm not sure where the error could be, as that is the only place in your code that uses array subscripts. Sorry I couldn't be more help on this one. Posted Image

The annoy thing thing is that I just know that it's going to be something maddeningly simple.

Thank You for trying. :( This switch function has worked in all of my other scripts (Rules.exe and Controler.exe Now I am trying to add it to my main script that runs on the lab computers.)

Update: All of my Computer Automation Scripts switches are working but the "Refresher" (the script mentioned above) script.

Edited by JonCross
Link to comment
Share on other sites

Ok, I think I found the issue, AutoIt is case sensitive, so $CmdLine is different than $cmdline.

AutoIt variable name are not case sensitive. nor are normal string compares UNLESS your using "==".

Thanks for the correction, I was not aware of this.

#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

Link to comment
Share on other sites

It's that shit torels's Zip.au3 that's causing your errors. It's unbelievable that people actually use that UDF.

Don't use it and it should be fine.

Btw, you should be aware of the fact that new versions of AutoIt are released for reasons. There is probably not one smart reason not to use the latest AutoIt.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Line -1:

Don't debug your script by running it as a build exe or a3x.

Use the available Autoit command line options to test run you script first so you get some usable data on the error location. (preventably passed it by Au3check first, now included in Autoit)

Ok, I think I found the issue, AutoIt is case sensitive, so $CmdLine is different than $cmdline.

AutoIt variable name are not case sensitive. nor are normal string compares UNLESS your using "==".

---

@JonCross: Check your Zip.au3 include file. nothing in your posted script seems to be able to trigger that particular error.

Thank You I don't know what it was in the Zip.au3 but I forgot that I had included it. I was trying something with unzipping files but it didn't work out I took the code out but forgot the included Zip.au3.

Link to comment
Share on other sites

It's that shit torels's Zip.au3 that's causing your errors. It's unbelievable that people actually use that UDF.

Don't use it and it should be fine.

Btw, you should be aware of the fact that new versions of AutoIt are released for reasons. There is probably not one smart reason not to use the latest AutoIt.

Thank You, I didn't know untill today that there was an updated version. I have updated my AutoIt as of today. :(

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