Jump to content
Chinoman10

Error running compiled script

Recommended Posts

Chinoman10

Hello everyone,

So... I get this error:

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

But only if I run the program after compiling. So if I open the script editor and run it, all is good, but if I just run the script from the Explorer, or run the .exe, they both give the error...

Any suggestions?

 

Thanks in advance,

Chinoman10.

Share this post


Link to post
Share on other sites
jchd

Refill line 1743 with a new cobalt nitroxide cartridge.

Seriously?


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
TheDcoder

jchd meant You need to provide more info if you want us to help you, TD :)


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) mean to do that to anybody!!!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites
jchd

Obviously! This can be found in good place in the cobalt nitroxide cartridge user manual.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
JohnOne

Add some simple error checking before every array use IsArray should suffice.

Also, why not just post your code here in future?

#cs ----------------------------------------------------------------------------
 AutoIt Version: 3.3.12.0
 Author:         Chinoman10
 Script Function:
    Disable useless Local Area Connection interfaces.
#ce ----------------------------------------------------------------------------
#include <Array.au3>
#include <AutoItConstants.au3>

#RequireAdmin

Start()

Func Start()

    Local $sFileName = 'output.txt'
    Local $sCommand = 'netsh interface show interface'
    Local $iPID = Run (@ComSpec & ' /C ' & $sCommand & ' > ' & $sFileName, @ScriptDir, @SW_HIDE)
    ProcessWaitClose($iPID)

    Local $sOutput = FileRead($sFileName)
    FileDelete($sFileName)

    Local $aArray = StringSplit(StringTrimRight(StringStripCR($sOutput), StringLen(@CRLF)), @CRLF)
    _ArrayDelete($aArray, "0-1")
    _ArrayDelete($aArray, "1")
    Local $aArray2 = ConvertArray1Dto2D($aArray)

    If @error Then
       MsgBox($MB_SYSTEMMODAL, "", "It appears there was an error.")
    Else
        ; Display the results.
        $sTitle = $aArray2[0][0]
        For $i = 1 To UBound($aArray2,2)-1
            $sTitle &= '|' & $aArray2[0][$i]
        Next
;       _ArrayDisplay($aArray2, 'Output', "1:99", 32+64, Default, $sTitle)
    EndIf

    ShutdownInterfaces($aArray2)
EndFunc


Func ShutdownInterfaces($aArray2)

;   netsh interface set interface name="Local Area Connection 2" admin=DISABLED
    For $i = 1 To UBound($aArray2)
        Local $sInterfaceName = $aArray2[$i][3]

        if StringRegExp($sInterfaceName, "Local Area Connection") And StringRegExp($aArray2[$i][0], "Enabled") Then
;           MsgBox($MB_SYSTEMMODAL, "Shuting down Interface", $sInterfaceName)
            Local $sCommand = 'netsh interface set interface name="' & $sInterfaceName & '" admin=disabled'

            Local $iPID = Run ( @ComSpec & ' /C  ' & $sCommand ,'',@SW_HIDE)
        ;   ProcessWaitClose($iPID)

        EndIf
    Next

    Exit

EndFunc

Func ConvertArray1Dto2D($aArray)
    Dim $aArray2[UBound($aArray)][4]

    For $i = 0 To UBound($aArray)-1
        $sTemp = StringRegExpReplace($aArray[$i], ' {2,20}', ',')

        $aSplitted = StringSplit($sTemp, ',')

        For $j = 1 To UBound($aSplitted)-1
            $aArray2[$i][$j-1] = $aSplitted[$j]
        Next
    Next

;   _ArrayDisplay($aArray2)

    Return $aArray2
EndFunc

 


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
Chinoman10

 

Add some simple error checking before every array use IsArray should suffice.

Also, why not just post your code here in future?

 Because I didn't want to make a long post, and I already had my code on GitHub, so why would I copy and paste it again? And it's also more readable there, since you can have tabs...

Anyways... I didn't do error checking because the code wouldn't give me any error if I open the editor and run the script... In my head, the script makes sense, and all works just fine, it just error's when running outside the editor... being it .au3 or .exe ...

Can you try on your computer and see if it gives you can error as well?

 

Thanks in advance,

Chinoman10.

Share this post


Link to post
Share on other sites
JohnOne

The forum will put your code in same size box, no matter how long it is, it's simple for forum members to see it rather than navigate away, some won't even bother clicking.

The whole point of error checking is so you can pinpoint the error, 

Before you try to use an array...

If Not IsArray($therarray) Or Ubound($thearray) < $whatever_you_think_it_should_be Then

    MsgBox(0,"Error Array", "Trying to use $thearray")

    Exit

EndIf

 


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
Chinoman10

But... if I run the script normally, I know where the code is having an error, since it tells me very clearly where it is.

My question isn't where it's having the problem, but knowing why it's "blowing up" only when not inside the editor.

You're misunderstanding the whole point of why I created this thread in the first place.

 

Thanks anyways.

Regards,

Chinoman10.

Share this post


Link to post
Share on other sites
JohnOne

I'm not missing the point, you have a problem with your compiled script, error checking will help you find exactly where that problem is in your compiled script and thus allow you to fix it.

If you refuse to believe that, then you lave a long haul ahead of you before you finally do.

Best of luck.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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

×