Jump to content

Incorrect subscript error on array use. Array Noob here.


Recommended Posts

Hello all,

I am having complications with arrays. I am new to arrays and still trying to wrap my head around them.

Couple of notes about the script I am creating. This script is used to input either a single computer name or multiple computer names and remove information pertaining to those computer names in a certain application. The section of the program for removing a single computer names information is working decent. The section of the code that pertains to removing the information for multiple PC's is not working currently. 

Line that errors out is 232-Getting Incorrect subscript or subscript dimension range exceeded

 

In the script I have the code open excel. Then input a list of computer names in the first column. Lines 210 to 213 show me that it is indeed pulling a single dimension array and I can even display it using array display.

 

I think I am originally pulling the information using the Excel UDF commands and wondering if the error is because I am trying to use that array it created to display in a listview? 

Thank you for any input 🙂

 

ComputerDecommLV.au3

Link to post
Share on other sites

I made that change: For $iIncrement = 0 to $aMax - 1

 

Its still showing that there is an error with the next line. 232-$aResult[$iIncrement][0] = "PC:" & $iIncrement . Showed no change in the error. For a single dimension array shouldn't there be just one [ ]?

Link to post
Share on other sites

With this change

"

For $iIncrement = 0 to $aMax -1
    $aResult[$iIncrement] = "PC:" & $iIncrement ; This is not working. Getting a incorrect subscript or subscript dimension range exceeded.
Next

"

I get a GUILISTVIEW error. I got the $aResult from a Excel UDF command that created the array. Can you use that information in a listview without converting it into another array?

Link to post
Share on other sites

I am aware of how to make it display using arraydisplay. I did successfully get it working but I do not like the GUI of arraydisplay or working with it. Listview seems better and other posters on the forums said they recommend using listview and not Excel UDF. So pulling the array with 

$aResult = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("A:A"), 2)

You cannot enter it into a listview?

Link to post
Share on other sites
8 minutes ago, slybry70 said:

Looks like since no one knows if excel UDF arrays and listview are compatible

Sorry but we know that it is compatible, but you would need to make a smaller replicate of the issue you are facing.  Your current code is not runable for us and it is way too large for my personal laziness to investigate.

Link to post
Share on other sites
On 2/16/2021 at 10:25 AM, slybry70 said:

I am having complications with arrays. I am new to arrays and still trying to wrap my head around them.

 

On 2/16/2021 at 10:25 AM, slybry70 said:

Thank you for any input

Let's be honest, you may be new to arrays but you appear to new to several other AutoIt scripting-related subjects.  Your script, as it currently stands, is a bit of a mess. There's no wonder why others may not be eager to try to help at this point.  You have way more issues with this script than your issue with arrays.

If you have the full version of Scite4Autoit3 installed and you add the following line to the top of your script and hit CTRL+F5, you will see NUMEROUS issues in the console such as: (Although they are warnings, some of those warnings could possibly cause serious logic issues and errors.  I didn't dig deep enough to know how serious all of the warnings are in your script)

#AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 -w 6 -d

 

  1.  'Local' specifier in global scope
  2.  A mixture of declared & undeclared variables.
  3. Several variables that are declared multiple times within the same function.
  4. Global variable defined inside a function.
  5. And I don' know how you came up with this snippet of code.  First you define a Global Excel object (inside a function), then immediately redefine the same object locally, and then 2 lines below that, you define the same object again.
    Func ExcelEntriesFunc()
    
        Global $oExcel = _Excel_Open() ;Create an Excel Object
        Local $oExcel = _Excel_Open()
        Local $oWorkbook = _Excel_BookNew($oExcel, 1)
        Local $oExcel = ObjGet("", "Excel.Application") ; Get an existing Excel Object
        If @error Then
            MsgBox(0, "ExcelTest", "Error Getting an active Excel Object. Error code: " & Hex(@error, 8))
            Exit
        EndIf
  6.  Plus your limited use of @error/return checking has given you a false sense that your script was successful in places that it obviously wasn't.
  7. There are more issues but I think you get my point.

If I were handed this script to get running, the first thing I would do is clean it up by removing any warnings, correcting any scope-related issues, and adding much more @error/return checking to make sure that the most important lines of code executed successfully before trying to continuing thru the script.  Then I would go line by line through the logic to make sure that it was doing exactly what it needed to do when it needed to do it.

Edited by TheXman
Link to post
Share on other sites

Thank you for the constructive reply first of all. I was not aware of the ctrl F5 with the line added to the script would show in verbose errors. It helps alot in the long run.

I am new to scripting in general and right now just barely limping along. Purchased a book online but no courses on Autoit are out there and almost no education book wise. I figured it would be obvious I am not a scripting expert let alone an AutoIT expert. 

I included my whole script in the posting because that is what normally is requested by those that help out on the forums. In the past I have gotten some nice and informative help on these forums so I hope that in the future that continues. 

I am grateful for your look at the script and will go through it again with this new error information. 

 

Thank you for taking the time to look at it TheXMan!

 

 

 

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

    No registered users viewing this page.

×
×
  • Create New...