Page 2 of 2

Re: Array/object wishlist (count, printarr, contains, other).

Posted: 11 Feb 2016, 14:16
by treashunter
Geekdudes Array_gui() function has proven very useful to me. I say +1 for a built in printarr function :)

http://imgur.com/5Cz1sOh

Re: Array/object wishlist (count, printarr, contains, other).

Posted: 25 Feb 2016, 09:57
by bichlepa
+1 for Obj.Count()
In the meantime I'll use this:

Code: Select all

class ObjectWithCounter
{
	count() 
	{
		return NumGet(&this + 4*A_PtrSize)
	}
}
MyObject:=new ObjectWithCounter()
MyObject.push("a")
MyObject.push("b")
msgbox, % MyObject.count()

Re: Array/object wishlist (count, printarr, contains, other).

Posted: 11 Apr 2016, 11:15
by kczx3
tidbit wrote:ran into this need for .key a couple times lately:

Due to the Objects auto-ABC sort, I need to turn 1D arrays into 2D arrays.
Each sub-array only consists of 1 array/object.


Usage: I have a treeview and a listbox. I can add items from the treeview to the listbox, when added to the LB, add to an object aswell. Something like: {TV_ID : TV_TEXT}. But since I want it in the order of which it's added to the LB (incase I need to rebuild the LB, if I delete an item), I need to make it a 2D Array, to avoid auto-sorting.

Code: Select all

arr:=[{"437742":"first"},{"122516":"second"},{"472125":"third"}]

; instead of this for every part I go through the array (this gets messier when other {}'s are needed for the for-loops):
for key, arr2 in arr
	for key, val in arr2
		msgBox, %key% = %val%

; it'd simply be:
for key, arr2 in arr
	msgBox, % arr2.key(1) " = " arr2.value(1)
	
; or if I only need the 3rd item from the list
msgbox % arr[3].key(1 " = " arr[3].value(1))
I too have had this incident come about time and time again. But today I was reading through this and if I interpret it correctly, it would do what we want, no?

Re: Array/object wishlist (count, printarr, contains, other).

Posted: 11 Feb 2018, 20:15
by Qriist
I second this motion, especially to use variables in array levels.


Also, per tidbit, BUMP.

Re: Array/object wishlist (count, printarr, contains, other).

Posted: 28 Mar 2018, 09:30
by Sam_
+1 for Obj.Count()

Re: Array/object wishlist (count, printarr, contains, other).

Posted: 07 Apr 2018, 18:30
by Flipeador
⠀⠀⠀⠀ItemCount := Object.Count() / ObjCount(Object)
Counts the number of items in an array/object.
+1 here too! :)