Jump to content

Recommended Posts

I'm trying to pass a nested array to a function, such that the function alters the inner array.

I was surprised to find that this minimal reproducible example, despite its use of ByRef, seems to pass a copy of the inner array to the function:

#include <Array.au3>

; a boring old array
Local $aInnerArray[5] = [1, 2, 3, 4, 5]

; a one-element array containing a reference to the other array
Local $aOuterArray[1] = [$aInnerArray]

; intention: take a nested array and alter its inner array
; reality: the inner array seems to be getting copied
Func ChangeIt(ByRef $aOuter)
    Local $aInner = $aOuter[0]
    $aInner[2] = 0
EndFunc

; Expected: [1, 2, 3, 4, 5]
; Actual: [1, 2, 3, 4, 5] ✔
_ArrayDisplay($aInnerArray, 'Before')

; $aOuterArray passed by-ref, should receive reference to $aInnerArray
; Therefore should change $aInnerArray to [1, 2, 0, 4, 5]
ChangeIt($aOuterArray)

; Expected: [1, 2, 0, 4, 5]
; Actual: [1, 2, 3, 4, 5] ✘
_ArrayDisplay($aInnerArray, 'After')

I suspect that either:

  1. the copy is taking place in the first line of the function (I couldn't find a way to access the inner array without first assigning it to a variable though); or
  2. ByRef doesn't propagate into inner levels of the data structure being passed, which seems less likely to me.

Could someone please point me in the right direction to get this working as intended?

Update: the answer

; WRONG:
; a one-element array containing a reference to the other array
Local $aOuterArray[1] = [$aInnerArray]

The assumption I made about this code is wrong—it actually copies $aInnerArray into $aOuterArray, so there are now two unrelated $aInnerArray instances.  It is not possible to store arrays in other arrays by reference.

If it is necessary to refer to a mutable array in multiple places, consider holding it in a global variable.  Where a collection of mutable arrays needs to be accessed in multiple places (as in my case), consider storing them in a global array and referring to each sub-array by index (also known as the Registry pattern).

Edited by LxP
add answer in response to replies

Share this post


Link to post
Share on other sites

I dont know if i got you right but

You havent even declared $aOuter ... and you don't wanna change or return it so why you need Byref?

 

if you just change

Func ChangeIt(ByRef $aOuter)
    Local $aInner = $aOuter[0]
    $aInner[2] = 0
EndFunc

with

Func ChangeIt(ByRef $aOuter)
    Local $aInner = $aOuter[0]
    $aInnerArray[2] = 0
EndFunc

it works like you expected... because You just change $aInnerArray[2].

But this would always happen even when you just write 

$aInnerArray[2] = 0

so what do you exactly want to do?

 

 

btw yes you can have 1 array which include multiple arrays 

Edited by Aelc

why do i get garbage when i buy garbage bags? <_<

Share this post


Link to post
Share on other sites

If you want to change the inner array you can use ByRef to the inner array, example:

#include <Array.au3>

; a boring old array
Local $aInnerArray[5] = [1, 2, 3, 4, 5]

; a one-element array containing a reference to the other array
Local $aOuterArray[1] = [$aInnerArray]

; intention: take a nested array and alter its inner array
; reality: the inner array seems to be getting copied
Func ChangeIt(ByRef $aInner)
    $aInner[2] = 0
EndFunc

; Expected: [1, 2, 3, 4, 5]
; Actual: [1, 2, 3, 4, 5] ✔
_ArrayDisplay($aInnerArray)

; $aOuterArray passed by-ref, should receive reference to $aInnerArray
; Therefore should change $aInnerArray to [1, 2, 0, 4, 5]
ChangeIt($aOuterArray[0])

; Expected: [1, 2, 0, 4, 5]
; Actual: [1, 2, 3, 4, 5] ✘
_ArrayInnerDisplay($aOuterArray[0])

Func _ArrayInnerDisplay(ByRef $aInner)
    _ArrayDisplay($aInner)
EndFunc

 

Share this post


Link to post
Share on other sites

Looks like an AutoIt bug to me. However, this works:

#include <Array.au3>

; a boring old array
Local $aInnerArray[5] = [1, 2, 3, 4, 5]

; outer array receives a COPY of $aInnerArray
Local $aOuterArray[1] = [$aInnerArray]
_ArrayDisplay($aOuterArray[0],"before")

ChangeIt($aOuterArray,0)
_ArrayDisplay($aOuterArray[0],"after")
_ArrayDisplay($aInnerArray,"$aInnerArray after (UNCHANGED)")

; intention: take a nested array and alter its inner array
Func ChangeIt(ByRef $aOuter, $index)
    _ChangeIt($aOuterArray[$index])
EndFunc

Func _ChangeIt(ByRef $aInner)
    $aInner[2] = 0
EndFunc

Also, your test is wrong, as $ainnerArray is itself never changed (a copy is stored in $aOuterArray). You should display $aAouterArray[0] afterwards.

Share this post


Link to post
Share on other sites

The reason it doesn't change the original inner array is because you never actually modified it. You modify a copy of it, then do absolutely nothing with that modified array expecting it to magically know that the copy of the array is supposed to modify the original array without being told to. Here's how it SHOULD have been written. Also, there's no bug here, it's working exactly as expected.

#include <Array.au3>

; a boring old array
Local $aInnerArray[5] = [1, 2, 3, 4, 5]

; a one-element array containing a reference to the other array
Local $aOuterArray[1] = [$aInnerArray]

; intention: take a nested array and alter its inner array
; reality: the inner array seems to be getting copied
Func ChangeIt(ByRef $aOuter)
    Local $aInner = $aOuter[0]
    $aInner[2] = 0
    $aOuter[0] = $aInner ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Add this line to modify $aOuter
EndFunc

; Expected: [1, 2, 3, 4, 5]
; Actual: [1, 2, 3, 4, 5] ✔
_ArrayDisplay($aInnerArray)

; $aOuterArray passed by-ref, should receive reference to $aInnerArray
; Therefore should change $aInnerArray to [1, 2, 0, 4, 5]
ChangeIt($aOuterArray)

; Expected: [1, 2, 0, 4, 5]
; Actual: [1, 2, 3, 4, 5] ✘
_ArrayDisplay($aOuterArray[0]) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Change this line because you're showing the ORIGINAL array, and not the contents of the $aOuterArray nested array.

 


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Thanks to everyone for your replies so far.

Why isn't $aOuter declared?

This is intended—$aOuter is a parameter name, for referencing any desired other variable at runtime.

Why use ByRef if not altering the top-level data structure being passed in?

Because I want to change the contents of the inner array, and if I don't pass the top-level, outer array by reference using ByRef, then my changes to the inner array will definitely not persist after the function returns.

Why not have a ByRef parameter for the inner array directly?

Because this is not viable outside my minimal reproducible example given above.

The example given above is the minimal code needed to demonstrate my issue.  In my actual code I wouldn't have access to a variable name for the inner array.

Why am I expecting the outer array's copy of the inner array to ever be modified?

These replies hit the nail on the head (emphasis is mine):

  • “Also, your test is wrong, as $ainnerArray is itself never changed (a copy is stored in $aOuterArray).”
  • “The reason it doesn't change the original inner array is because you never actually modified it. You modify a copy of it, then do absolutely nothing with that modified array expecting it to magically know that the copy of the array is supposed to modify the original array without being told to.”

As a formally qualified software engineer I know better than to expect magic synchronisation of two distinct data structures in memory.  What I didn't know was that two distinct data structures existed.  Here's the source of my misunderstanding:

Local $aOuterArray[1] = [$aInnerArray]

In other languages, $aOuterArray would get a reference to $aInnerArray.  In AutoIt, $aOuterArray gets a copy of $aInnerArray.  In other words, I didn't know I had made two $aInnerArrays at this point.  With this knowledge I can move forwards.

My new question

Is there a way to store an inner array inside an outer array by reference, such that:

  • two different outer arrays can reference the same inner array; and
  • changes to the inner array are visible within both outer arrays?

If not, I'll resort to global arrays and store indexes instead.

Share this post


Link to post
Share on other sites

AutoIt doesn't have a reference operator.

Yet, in limited cases (fixed sizes and datatypes) one might use structs to achieve something like that, (awful code emoji).

Local $tInner = DllStructCreate("int[5]")
For $i = 1 To 5
    DllStructSetData($tInner, 1, $i, $i)
Next

Local $tOuterA = DllStructCreate("wchar[12];ptr")
Local $tOuterB = DllStructCreate("wchar[12];ptr")

; init both structs with distinct strings but same inner array
DllStructSetData($tOuterA, 1, "String A")
DllStructSetData($tOuterA, 2, DllStructGetPtr($tInner))
Local $tInnerA = DllStructCreate("int[5]", DllStructGetData($tOuterA, 2))

DllStructSetData($tOuterB, 1, "String B")
DllStructSetData($tOuterB, 2, DllStructGetPtr($tInner))
Local $tInnerB = DllStructCreate("int[5]", DllStructGetData($tOuterB, 2))

$cw("Before:")
vd($tOuterA)
vd($tInnerA)
vd($tOuterB)
vd($tInnerB)

ChangeMe($tOuterB)

$tInnerA = DllStructCreate("int[5]", DllStructGetData($tOuterA, 2))
$tInnerB = DllStructCreate("int[5]", DllStructGetData($tOuterB, 2))
$cw("After:")
vd($tOuterA)
vd($tInnerA)
vd($tOuterB)
vd($tInnerB)

Func ChangeMe(ByRef $t)
    DllStructSetData($t, 1, "B chain!")
    ; local copy to work with
    Local $tt = DllStructCreate("int[5]", DllStructGetData($t, 2))
    DllStructSetData($tt, 1, 0, 3)
    ; same necessary write back step as with arrays!
    DllStructSetData($t, 2, DllStructGetPtr($tt))
EndFunc

$cw() is a consolewrite, vd() is a variable dump. Output is as follows:

Before:
Struct             (32) @:000001C4C9191FC0 (structure alignment is unknown)
      wchar[12]   'String A'
      ptr         0x000001C4C91CB170

Struct             (20) @:000001C4C91CB170 (structure alignment is unknown)
      int[5]
                  1
                  2
                  3
                  4
                  5

Struct             (32) @:000001C4C9191FF0 (structure alignment is unknown)
      wchar[12]   'String B'
      ptr         0x000001C4C91CB170

Struct             (20) @:000001C4C91CB170 (structure alignment is unknown)
      int[5]
                  1
                  2
                  3
                  4
                  5

After:
Struct             (32) @:000001C4C9191FC0 (structure alignment is unknown)
      wchar[12]   'String A'
      ptr         0x000001C4C91CB170

Struct             (20) @:000001C4C91CB170 (structure alignment is unknown)
      int[5]
                  1
                  2
                  0
                  4
                  5

Struct             (32) @:000001C4C9191FF0 (structure alignment is unknown)
      wchar[12]   'B chain!'
      ptr         0x000001C4C91CB170

Struct             (20) @:000001C4C91CB170 (structure alignment is unknown)
      int[5]
                  1
                  2
                  0
                  4
                  5

Note that we indeed changed item #3 of inner array inside struct $tOuterB but value got changed in $tOuterA as well since the pointers are the same.

Also note that I highly recommend against use of nested arrays as well as such above struct constructs!


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
2 hours ago, jchd said:

AutoIt doesn't have a reference operator.

Thanks for confirming.  I greatly appreciate the time you have put into your code example using structs.

I think in my case, the best alternative will be to adopt the Registry pattern, store my arrays in another global array, and pass around a global array index as a reference for each sub-array.

2 hours ago, jchd said:

Also note that I highly recommend against use of nested arrays as well as such above struct constructs!

I'm guessing that this is mostly due to performance?

I suppose my proposed array-of-arrays could be a 2D array instead since each sub-array is guaranteed to be of a certain length.  Is that a significant improvement in your view?

Share this post


Link to post
Share on other sites

If the array content is numerical only (or can be encoded as such), I would suggest looking into using matrices instead; they're natively 2D, limited in size only by your virtual memory, and can be accessed/manipulated orders of magnitude faster than AutoIt arrays (incl. file I/O).

Share this post


Link to post
Share on other sites

My arrays contain varying content in this case—numbers, strings, handles, other arrays (I'm technically trying to emulate object instances).  Nonetheless, I'll keep your tip in mind for another time.  Thank you.

Share this post


Link to post
Share on other sites

Then if the structure looks more like a tree, you can probably use a scripting.dictionary (search for that).

Else, a native 2D array with the maximum number of column could work too.

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Colduction
      Hi dear friends!, i'm sorry for creating a new thread (a new problem), i have over than 9 lists that i want to combine them to be this (in this example, there are 3 test files):


      I've written a little code for splitting main information, but i really confused how to make results as "Output.txt", here is that code:
       
      $sRegex_1 = StringRegExp(FileRead("1.txt"), '(?s:(?<=\=\=\r\n)(.*?)(?=\r\n\=\=))', 3) $sRegex_2 = StringRegExp(FileRead("2.txt"), '(?s:(?<=\=\=\r\n)(.*?)(?=\r\n\=\=))', 3) $sRegex_3 = StringRegExp(FileRead("3.txt"), '(?s:(?<=\=\=\r\n)(.*?)(?=\r\n\=\=))', 3) For $i = 0 To UBound($sRegex_1) - 1 ConsoleWrite($sRegex_1[$i] & @CRLF) For $j = 0 To UBound($sRegex_2) - 1 ConsoleWrite($sRegex_2[$j] & @CRLF) For $k = 0 To UBound($sRegex_3) - 1 ConsoleWrite($sRegex_3[$k] & @CRLF) Next Next Next  
    • By nacerbaaziz
      hello evrybody
      here is an example about how to split your texts using a delimiter with the ability to select how much of delimiters shows in each colum  with $i_number
      e.g
      you have a long text and you want to split it in an array
      that evry colum have a number (n) of lines
      i made a function that do that for you
      just call it with a three params
      $s_text
      your text
      $i_number
      the number that you want to put in each col
      $s_siparator
      the siparator
      default is "|"
      here is the function with example
      i hope that it will be useful for you
       
      ****
       
      #include <Array.au3> $s_txt = "some text1some text2|some text3|some text4|some text5|some text6" $array = splitText($s_txt, 2) _ArrayDisplay($array) Func splitText($s_text, $i_number, $s_siparator = "|") Local $a_TXT = StringSplit($s_text, $s_siparator) Local $a_Return[$a_TXT[0] + 1] If ($a_TXT[0] <= $i_number) Or ($i_number <= 0) Then ReDim $a_Return[2] $a_Return[0] = 1 $a_Return[1] = $s_text Return $a_Return EndIf Local $i_Processed = 1, $i_arrayProcessed = 1 Do For $i = $i_Processed To ($i_Processed + $i_number) - 1 If ($a_TXT[0] < $i) Then ExitLoop If Not ($a_Return[$i_arrayProcessed]) Then $a_Return[$i_arrayProcessed] = $a_TXT[$i] Else $a_Return[$i_arrayProcessed] &= $s_siparator & $a_TXT[$i] EndIf $i_Processed += 1 Next $i_arrayProcessed += 1 Until ($a_TXT[0] < $i_Processed) ReDim $a_Return[$i_arrayProcessed] $a_Return[0] = $i_arrayProcessed - 1 Return $a_Return EndFunc ;==>splitText
      accept my greetings
      thanks to
      @Dan_555
      for his notes
       
    • By MesterPerfect
      good morning
      this is the first post here in the autoit forums
      i hope that you can help me in my problem
      i have a JSON encoded
      it a map of my forums
      where i want to make a treeview that have the same type of map
      e.g
      a system (as category)
      windows (as sub category)
      software (as an child item in the windows category)
      .....
      i don't know how to do that
      so, i know that i can do that using the json functions
      but i need your help about how we can do it as the type that i told you
      by the way i need to put the sub info for each item in an array that give me the ability to manage my items
      e.g
      can post thread
      can reply
      message cound ...
      you just give me a small example and i can continue.
      am sorry if this against the rules of the forum.
      but i realy searched a lot but i couldn't
      i hope some one give me the way.
      thank you very much in advance
       
      here is the link of json forum
      https://www.autoitscript.com/forum/topic/148114-a-non-strict-json-udf-jsmn/
      and here is my encoded json file
       
      { "tree_map": { "0": [ 1, 5, 6, 7 ], "1": [ 2 ], "2": [ 4 ], "5": [ 3 ], "6": [ 8 ], "8": [ 9, 10 ] }, "nodes": [ { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 1, "node_id": 1, "node_name": null, "node_type_id": "Category", "parent_node_id": 0, "title": "Main category", "type_data": {} }, { "breadcrumbs": [ { "node_id": 1, "title": "Main category", "node_type_id": "Category" } ], "description": "", "display_in_list": true, "display_order": 1, "node_id": 2, "node_name": null, "node_type_id": "Forum", "parent_node_id": 1, "title": "Main forum", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 1, "title": "Main category", "node_type_id": "Category" }, { "node_id": 2, "title": "Main forum", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 1, "node_id": 4, "node_name": null, "node_type_id": "Forum", "parent_node_id": 2, "title": "my forums1", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 2, "node_id": 5, "node_name": null, "node_type_id": "Category", "parent_node_id": 0, "title": "Perfect", "type_data": {} }, { "breadcrumbs": [ { "node_id": 5, "title": "Perfect", "node_type_id": "Category" } ], "description": "", "display_in_list": true, "display_order": 2, "node_id": 3, "node_name": null, "node_type_id": "Forum", "parent_node_id": 5, "title": "ahmed", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 3, "node_id": 6, "node_name": null, "node_type_id": "Forum", "parent_node_id": 0, "title": "autoit", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 6, "title": "autoit", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 3, "node_id": 8, "node_name": null, "node_type_id": "Forum", "parent_node_id": 6, "title": "examples", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 6, "title": "autoit", "node_type_id": "Forum" }, { "node_id": 8, "title": "examples", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 3, "node_id": 9, "node_name": null, "node_type_id": "Forum", "parent_node_id": 8, "title": "GUI", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 6, "title": "autoit", "node_type_id": "Forum" }, { "node_id": 8, "title": "examples", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 31, "node_id": 10, "node_name": null, "node_type_id": "Forum", "parent_node_id": 8, "title": "windowEX", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 4, "node_id": 7, "node_name": null, "node_type_id": "Category", "parent_node_id": 0, "title": "vbs", "type_data": {} } ] }  
    • By nooneclose
      I need to dynamically resize my 2d array while looping. 
      I know this code:
      ReDim $rArray[UBound($rArray) + 1] works for the rows, however, I also need to increase the columns. How would i go about increasing both rows and columns while looping? 
    • By Zaoka
      Hi guys
      Need little help with filtering.
      I'm trying to filter specific weeks from power pivot table using this code recorded with Excel VBA :
       
      #include <Excel.au3> Global $oExcel = _Excel_Open() Global $oWorkbook = _Excel_BookOpen($oExcel, "C:\Users\....\Orders.xlsb") $oWorkbook.PivotTables("PivotTable1").PivotFields( _ "[Report 2].[Week].[Week]").VisibleItemsList = Array( _ "[Report 2].[Week].&[10]", "[Report 2].[Week].&[11]", _ "[Report 2].[Week].&[12]", "[Report 2].[Week].&[13]", _ "[Report 2].[Week].&[14]", "[Report 2].[Week].&[15]") But get error
      error: Array(): undefined function. Not sure how to resolve this.
×
×
  • Create New...