ObjCount() - Call to nonexistent function | 2.0-a097-60f26de Topic is solved

Report problems with documented functionality
User avatar
Flipeador
Posts: 1204
Joined: 15 Nov 2014, 21:31
Location: Argentina
Contact:

ObjCount() - Call to nonexistent function | 2.0-a097-60f26de

15 Jun 2018, 12:18

Code: Select all

MsgBox ObjCount({}) ; Call to nonexistent function
MsgBox {1:0,2:0}.Count() ; 2
.. and it does not appear in the list of methods:
https://lexikos.github.io/v2/docs/objects/Object.htm
burque505
Posts: 1732
Joined: 22 Jan 2017, 19:37

Re: ObjCount() - Call to nonexistent function | 2.0-a097-60f26de

15 Jun 2018, 14:08

Not in the list of methods, but the example is there below:
Count := Object.Count()
Returns the number of key-value pairs present in the object.

Code: Select all

MsgBox % {A: 1, Z: 26}.Count()    ;  2
MsgBox % ["A", "B", "C"].Count()  ;  3
MsgBox % ["A",    , "C"].Count()  ;  2
Edit: I do see it says Object.Count, and not ObjCount :D

Just ran this, the msgbox says "4":

Code: Select all

myObject := Array("1","2","3","4")
msgbox myObject.Count()
Regards,
burque505
Last edited by burque505 on 15 Jun 2018, 14:18, edited 1 time in total.
User avatar
Flipeador
Posts: 1204
Joined: 15 Nov 2014, 21:31
Location: Argentina
Contact:

Re: ObjCount() - Call to nonexistent function | 2.0-a097-60f26de

15 Jun 2018, 14:17

Each method also has an equivalent function, which can be used to bypass any custom behaviour implemented by the object [..]
btw: works well on AHKv1.
burque505
Posts: 1732
Joined: 22 Jan 2017, 19:37

Re: ObjCount() - Call to nonexistent function | 2.0-a097-60f26de

15 Jun 2018, 14:19

I see what you mean now. Point taken.
EDIT: As you say, it works in V1, with the appropriate tweaking:

Code: Select all

myObject := Array("1","2","3","4")
x := myObject.Count()
msgbox %x% ; "4"

y := ObjCount(myObject) ; also "4"
msgbox %y%
coffee
Posts: 133
Joined: 01 Apr 2017, 07:55

Re: ObjCount() - Call to nonexistent function | 2.0-a097-60f26de

15 Jun 2018, 15:46

Flipeador wrote:
Each method also has an equivalent function, which can be used to bypass any custom behaviour implemented by the object [..]
btw: works well on AHKv1.
It's not in the built-in function array in script.cpp. (Lexikos probably overlooked it, since it's just one line missing).

BIFn(ObjCount, 1, 1, BIF_ObjXXX),

After BIFn(ObjClone, 1, 1, BIF_ObjXXX),

If you need it right now to finish something.
User avatar
Flipeador
Posts: 1204
Joined: 15 Nov 2014, 21:31
Location: Argentina
Contact:

Re: ObjCount() - Call to nonexistent function | 2.0-a097-60f26de

15 Jun 2018, 15:54

Yes, you are right. I had not seen the source code. It's nothing important. Thank you. :D
:wave:
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: ObjCount() - Call to nonexistent function | 2.0-a097-60f26de  Topic is solved

18 Jun 2018, 19:08

Yes, it was overlooked when I merged with v1. The v1 code base uses a giant if-else-if ladder instead of a table of functions.

[2020-06-28: Note that ObjCount has since been renamed to ObjOwnPropCount, although more typically one would use myMap.Count. See v2.0-a104-3e7a969d.]
Last edited by lexikos on 28 Jun 2020, 03:00, edited 1 time in total.
Reason: update

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 17 guests