Jump to content
realtebo

[Solved] Problem with array

Recommended Posts

realtebo

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
jdelaney

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
water

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 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
jdelaney

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")
  • Like 1

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
realtebo

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

×