simple 2D-array: use variable with removeat() method Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Ricaz2020
Posts: 2
Joined: 16 Apr 2020, 03:25

simple 2D-array: use variable with removeat() method

16 Apr 2020, 04:13

Hi there!
I do apologise if I'm going to use the wrong terminology: I've tried to do my homework, but have limited understanding of both programming and the technical jargon.

I have a two-dimensional array, named Array2D, which has a variable number of sub -arrays.
I'd say it is an object-based, simple array (can a simple array be a multi-dimensional array?).

I want to use a loop to remove the first item of each of the sub-arrays in Array2D.
I though to use the method removeat().
As far as I know to use removeat() method on 2D arrays, one indicates the the "index" of the sub-array with a "dot+number+dot" just after the object name, as in the following example to remove the first item of the third sub-array: Arrayname.3.removeat(1)

In the loop I'd like to use a variable to indicate the "index" of the sub-array.
Something like the example I've pasted here below; needless to say, AHK does not seem to like this (Error: This line does not contain a recognized action.)

Code: Select all

Loop, 3
		{
		Array2D.%A_Index%.removeat(1)
		}
Could anyone help me with understanding how this is supposed to be done?

Thank you!
Odlanir
Posts: 659
Joined: 20 Oct 2016, 08:20

Re: simple 2D-array: use variable with removeat() method  Topic is solved

16 Apr 2020, 04:53

Code: Select all

arr := []
arr[1] := [1,2,3,4,5,6,7]
arr[2] := [11,12,13,14,15,16,17]
arr[3] := [21,22,23,24,25,26,27]
Loop 3 {
   arr[A_Index].RemoveAt(1)
}
MsgBox % arr[1].1 "`n" arr[2].1 "`n" arr[3].1
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
Ricaz2020
Posts: 2
Joined: 16 Apr 2020, 03:25

Re: simple 2D-array: use variable with removeat() method

16 Apr 2020, 05:23

Thanks, Odlanir, of course it works with the syntax you advised!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 279 guests