What's the difference: Object.Length() vs. NumGet(&Object + 4*A_PtrSize) Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
magicinmath
Posts: 140
Joined: 12 Apr 2017, 23:03

What's the difference: Object.Length() vs. NumGet(&Object + 4*A_PtrSize)

19 May 2017, 19:58

Is one better than the other?

Is there a difference?
Guest

Re: What's the difference: Object.Length() vs. NumGet(&Object + 4*A_PtrSize)

19 May 2017, 20:36

What's the difference: Object.Length() vs. NumGet(&Object + 4*A_PtrSize)

Basically: Use the first one. And never use the second one.
https://autohotkey.com/boards/viewtopic ... 578#p21578
magicinmath
Posts: 140
Joined: 12 Apr 2017, 23:03

Re: What's the difference: Object.Length() vs. NumGet(&Object + 4*A_PtrSize)

19 May 2017, 20:56

Guest wrote:
What's the difference: Object.Length() vs. NumGet(&Object + 4*A_PtrSize)

Basically: Use the first one. And never use the second one.
https://autohotkey.com/boards/viewtopic ... 578#p21578


This example demonstrates why I thought the second is better if I need the number of elements in an array and not just the max index?

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


More realistically I see the concern as:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Last edited by magicinmath on 19 May 2017, 21:16, edited 2 times in total.
IMEime
Posts: 411
Joined: 20 Sep 2014, 06:15

Re: What's the difference: Object.Length() vs. NumGet(&Object + 4*A_PtrSize)  Topic is solved

19 May 2017, 21:13

And, you have to see this one.

Length method
https://autohotkey.com/docs/objects/Obj ... gth_v1121+
'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.'

Code: [Select all] [Download] GeSHi © Codebox Plus

obj := []
obj["-1"] := ""
obj["1"] := ""
obj["a"] := ""

MsgBox % ""
. obj.Length() "`n"
. obj.SetCapacity(0)

Return to “Ask For Help”

Who is online

Users browsing this forum: No registered users and 66 guests