Code: Select all
AR := {"l" : ["A", "B", "C"], "m" : ["D", "E", "F"]}
MsgBox % AR.Length()
what I'm doing wrong !?
Code: Select all
AR := {"l" : ["A", "B", "C"], "m" : ["D", "E", "F"]}
MsgBox % AR.Length()
Returns the length of a linear array beginning at position 1; that is, the highest positive integer key contained by the object, or 0 if there aren't any.
- https://autohotkey.com/docs/objects/Object.htm#Length
Code: Select all
AR := {"l" : ["A", "B", "C"], "m" : ["D", "E", "F"]}
size := 0
For key, value in AR
size++
MsgBox % size
Thank you bro !Paneb wrote:Dunno if there is easier than this, but it is working:Code: Select all
AR := {"l" : ["A", "B", "C"], "m" : ["D", "E", "F"]} size := 0 For key, value in AR size++ MsgBox % size
What if i need to read the dict by Index ?tidbit wrote:I have been asking for such a thing for a while now: https://autohotkey.com/boards/viewtopic.php?f=13&t=7101
" .count() ; this is what I'd expect .length() to do, but since it doesn't, .count() could exist aswell
counts the number of items in an array or object, regardless of type ..."
feel free to post in that topic to support the idea.
Code: Select all
AR := {"l" : ["A", "B", "C"], "m" : ["D", "E", "F"]}
MsgBox % AR["l"][1]
MsgBox % AR[1][1]
Code: Select all
AR := {l: ["A", "B", "C"], 1: ["D", "E", "F"]}
MsgBox % AR["l", 1]
MsgBox % AR[1, 1]
I'm expecting the second would retrieve "A"Guest wrote:Code: Select all
AR := {l: ["A", "B", "C"], 1: ["D", "E", "F"]} MsgBox % AR["l", 1] MsgBox % AR[1, 1]
https://autohotkey.com/docs/Objects.htm ... ive_Arraysdsewq1LYJ wrote:Guest wrote:I'm expecting the second would retrieve "A"
First element of first key.
Thanks bro ! but why not I just iterate through this array by For Loop looolGuest wrote:https://autohotkey.com/docs/Objects.htm ... ive_Arraysdsewq1LYJ wrote:Guest wrote:I'm expecting the second would retrieve "A"
First element of first key.
Users browsing this forum: Araphen, DataLife, Google [Bot], ShatterCoder and 260 guests