realtebo

[Solved] Problem with array

5 posts in this topic

#1 ·  Posted (edited)

I'm not albe to understand how to handle Array.

I need a DYNAMIC array, because I've not idea of how mouch data i'll include in it.

and every 'row' of the array must have 2 elements;

So i've

Global $confirmed_po_links[0][0]

and in the function when this is populated. ...

Local $new_size     = UBound($confirmed_po_links) + 1;
ReDim $confirmed_po_links[$new_size][2];
$confirmed_po_links[$new_size][1] = $link.innerText;  **** THE ERROR HAPPENS HERE ***
$confirmed_po_links[$new_size][2] = $link.href

But I got some errors about array dimensions... why? in the row with the asterisks

 


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

Edited by realtebo

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Local $new_size     = UBound($confirmed_po_links) + 1;
ReDim $confirmed_po_links[$new_size][2];
$confirmed_po_links[$new_size-1][1] = $link.innerText;  **** THE ERROR HAPPENS HERE (no longer!) ***
$confirmed_po_links[$new_size-1][2] = $link.href])

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Shouldn't it be like this (2nd dimension goes from 0 to 1):

Local $new_size = UBound($confirmed_po_links) + 1
ReDim $confirmed_po_links[$new_size][2]
$confirmed_po_links[$new_size-1][0] = $link.innerText
$confirmed_po_links[$new_size-1][1] = $link.href)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Oops, didn't even see that error.

Note to OP, you should post a script that's reproducible (what you provided is not) if you want all corrections fixed on the first go around.

Like this:

#include <Array.au3>
Local $confirmed_po_links[1][2]=[["testa","test1"]]
_ArrayDisplay($confirmed_po_links,"before")
ReDim $confirmed_po_links[UBound($confirmed_po_links)+1][2]
$confirmed_po_links[UBound($confirmed_po_links)-1][0] = "testb"
$confirmed_po_links[UBound($confirmed_po_links)-1][1] = "test2"
_ArrayDisplay($confirmed_po_links,"after")
1 person likes this

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

OK, so array index starts from 0...

Corrected and, all is working now, thanks !

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