Sign in to follow this  
Followers 0
magician13134

_ArrayAdd with two-dimensional arrays?

6 posts in this topic

#1 ·  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

Share this post


Link to post
Share on other sites

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


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  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

Share this post


Link to post
Share on other sites

#4 ·  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

Share this post


Link to post
Share on other sites

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

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
Sign in to follow this  
Followers 0