Jump to content

Recommended Posts

Posted (edited)

The help file only showed it working on a one-dimensional array, and I keep getting an "Array variable has incorrect number of subscripts or subscript dimension range exceeded." error after using it. My question is, does it work for two-dimensional arrays? Here's a snippet of the code I'm using:

Global $bookmarks[1][2]
$bookmarks[0][0] = GUICtrlCreateMenu("Bookmarks")

Func loadBookmarks($section = "Roots", $index = 0)
    GUICtrlSetData($edit, @CRLF & "Loading bookmarks...", "append")
    $file = @ScriptDir & "\res\bookmarks.ini"
    Local $i
    Local $temp = IniReadSection($file, $section)
    If not IsArray($temp) Then MsgBox(48, "Error!", "Could not load " & $file & @CRLF & "There will be no bookmarks")
    For $i = 1 to $temp[0][0]
        If $temp[$i][1] == "folder" Then
            _ArrayAdd($bookmarks, GUICtrlCreateMenu($temp[$i][0], $bookmarks[$index][0]))
            loadBookmarks($temp[$i][0], $index + 1)
        Else
            MsgBox(0, "", $index)
            _ArrayAdd($bookmarks, GUICtrlCreateMenuItem($temp[$i][0], $bookmarks[$index - 1][0])) ;<-- ERROR IS ON THIS LINE, ($index - 1) = 0
            $bookmarks[$i][1] = $temp[1][1]
            GUICtrlSetTip($bookmarks[$i][0], $bookmarks[$i][1])
        EndIf
    Next
    GUICtrlSetData($edit, @CRLF & "Finished loading bookmarks", "append")
EndFunc

[EDIT]

Hmm, I changed the _ArrayAdd call to this "_ArrayAdd($bookmarks[0][0], GUICtrlCreateMenu($temp[$i][0], $bookmarks[$index][0]))" and there aren't any errors, but I think that's adding a value to the second dimension instead of the first...

[EDIT]

Nope, of course it was a problem on my end again.

Delete anyone?

Edited by magician13134
  • Developers
Posted

The help file only showed it working on a one-dimensional array, and I keep getting an "Array variable has incorrect number of subscripts or subscript dimension range exceeded." error after using it. My question is, does it work for two-dimensional arrays? \

Simple: It doesn't. this UDF only works with single dimension Arrays.

Just code it yourself using redim.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted (edited)

I posted 2D-enabled versions called __ArrayAdd() and __ArrayConcatenate(). Note the double underscores to differentiate these from the standard UDF function names. If these are not exactly what you need, they should at least give you somewhere to start from.

:)

Edit: for readability

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Posted (edited)

Wait... it doesn't work? It seems to be working in my code.

Later in my script I'm going to need to use some fountions like _ArraryDelete on a two dimensional array... Will that not work?

For instance I have a grid and I want to be able to delete cells, rows, and columns, and the grid is represented my a two-dimensional array... How would I do that?

Edited by magician13134
  • 1 year later...
  • 2 years later...
Posted

while using the "SQLite.au3" functions i recieve an error that says there is no EndFunc for _ArrayAdd in "Array.au3" but when i checed the include code there is, does anyone knows why i recieve this error?

Or how ti fix it?

thanks in advance

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