Sign in to follow this  
Followers 0
WaitingForZion

Array Dimension Problems

4 posts in this topic

I've defined a function accepting three parameters, one of which is an array using byref. My function calls the UDF _ArrayAdd to add newly defined arrays to the array passed to the function. The function appears to run properly so far, but when I try to access one of the elements of the added arrays from the referenced main array, AutoIt generates a range error. I attempted to access the 2nd element of the sub array like this: $main_array[1][1]. This is clearly not a index out of bounds error. I've tested my function from within, and the successful execution of my function confirms that there is no error as to the number of elements in the array. The problem is, after I am done adding elements to the array in my function, I am unable to access the elements of the sub-array, or as it seems even the sub arrays themselves. I'd prefer not to post my code here, because I want to keep my project without competitors for now, but if it is absolutely necessary to show my code in order for you to help me, just ask, and I will display it.


Spoiler

"This then is the message which we have heard of him, and declare unto you, that God is light, and in him is no darkness at all. If we say that we have fellowship with him, and walk in darkness, we lie, and do not the truth: But if we walk in the light, as he is in the light, we have fellowship one with another, and the blood of Jesus Christ his Son cleanseth us from all sin. If we say that we have no sin, we deceive ourselves, and the truth is not in us. If we confess our sins, he is faithful and just to forgive us our sins, and to cleanse us from all unrighteousness. If we say that we have not sinned, we make him a liar, and his word is not in us." (I John 1:5-10)

 

Share this post


Link to post
Share on other sites



You should use _ArrayDisplay($main_array) to check if all elements that should be in the array, are actually in the array :mellow:

Share this post


Link to post
Share on other sites

WaitingForZion,

Do I understand that you are setting the newly-created arrays as elements of the first array? If that is the case, you cannot address the "second-order" arrays directly. You will have to extract them first:

#include <Array.au3>

Global $aBig_Array[2]

Global $aLittle_Array[2] = ["Element 1", "Element 2"]

$aBig_Array[1] = $aLittle_Array

_ArrayDisplay($aBig_Array)

$aExtracted_Array = $aBig_Array[1]

_ArrayDisplay($aExtracted_Array)

I hope that is clear. :mellow:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Nesting is not same thing as additional dimensions. If you've stored an array as an element in another array (nested them) then your syntax is wrong. The nested array must be copied out to its own temp variable to perform any operations on it.

If you're going to ask questions about references that don't work, post a short running demo script that will replicate the issue.

This demo is for nested arrays:

#include <Array.au3>

Global $aTemp1[2] = ["A", "B"]
Global $aTemp2[2] = ["C", "D"]
Global $aTemp3[1], $aWorking
Global $aParent[3] = [$aTemp1, $aTemp2, $aTemp3]

_UpdateNestedArray()
$aTemp3 = $aParent[2]
_ArrayDisplay($aTemp3, "$aTemp3")


Func _UpdateNestedArray()
    Local $aWorking1 = $aParent[0]
    Local $aWorking2 = $aParent[1]
    For $n = 0 To UBound($aWorking2) - 1
        _ArrayAdd($aWorking1, $aWorking2[$n])
    Next
    $aParent[2] = $aWorking1
EndFunc

:mellow:


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

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