Delete a column rather than a row using Array.remove(?).

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Heezea
Posts: 59
Joined: 30 Sep 2013, 21:33

Delete a column rather than a row using Array.remove(?).

02 Feb 2015, 11:40

How can I delete a column from an array? Array.Remove(5) removes the 5th row with no problem, but how can I remove the 5th column? I haven't set the array up as key-value pairs, but just as a multidimensional simple array with several columns and several rows.

I can't find the answer to this anywhere on the forums or the help documentation.

I've tried:

Code: Select all

a.Remove(a.1.5, a.MaxIndex().5)
a.Remove(a.1.5)
a.Remove(a[1, 5], a[a.MaxIndex(), 5])
I don't know what else to try. Can anyone help please?
toralf
Posts: 868
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: Delete a column rather than a row using Array.remove(?).

02 Feb 2015, 13:14

You'll have to loop through your rows and delete the individual column value
ciao
toralf
jpginc
Posts: 124
Joined: 29 Sep 2013, 22:35

Re: Delete a column rather than a row using Array.remove(?).

02 Feb 2015, 19:25

Something like this?

Code: Select all


test := [[1,2],[1,2]]
removeColumn(test, 1)
MsgBox % test[1][1] ;shows 2
MsgBox % test[2][2] ;shows "" because there is no element there anymore
ExitApp
;This function modifies the original array!
;@arr 
;  the Array to modify
;@column
;  The column index to remove
removeColumn(arr, column)
{
   loop, % arr.maxIndex()
  { 
    arr[A_index].remove(column)
  }
  return
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, inseption86, jaka1 and 334 guests