[a104]: Object _Enum error Topic is solved

Discuss the future of the AutoHotkey language
User avatar
aseiot
Posts: 33
Joined: 05 Mar 2017, 04:25

[a104]: Object _Enum error

17 Aug 2019, 19:18

Following code cause script error:
Error: Type mismatch
Specifically: _Enum

Code: Select all

for k, v in {A : 1, B : 2}
{
	MsgBox k ":" v
}
User avatar
aseiot
Posts: 33
Joined: 05 Mar 2017, 04:25

Re: [a104]: Object _Enum error  Topic is solved

17 Aug 2019, 19:30

After reading the new help document.
I realize the code should be

Code: Select all

for k, v in {A : 1, B : 2}.OwnProps()
{
	MsgBox k ":" v
}
:?
Helgef
Posts: 4031
Joined: 17 Jul 2016, 01:02
Contact:

Re: [a104]: Object _Enum error

18 Aug 2019, 03:18

or for k, v in map('A', 1, 'B', 2)

Cheers.
User avatar
Maestr0
Posts: 81
Joined: 05 Dec 2013, 17:43

Re: [a104]: Object _Enum error

18 Aug 2019, 04:09

in the help file on Process Functions the second example throws an error "Error: 0x80020011 - Does not support a collection."

Specifically: _NewEnum

Line#
004: Gui := GuiCreate(, "Process List")
005: LV := Gui.Add("ListView", "x2 y0 w400 h500", "Process Name|Command Line")
---> 006: For process in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process")
007: LV.Add("", process.Name, process.CommandLine)
008: Gui.Show()

Code: Select all

; throws error
Gui := GuiCreate(, "Process List")
LV := Gui.Add("ListView", "x2 y0 w400 h500", "Process Name|Command Line")
for process in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process")
    LV.Add("", process.Name, process.CommandLine)
Gui.Show

Code: Select all

; works
Gui := GuiCreate(, "Process List")
LV := Gui.Add("ListView", "x2 y0 w400 h500", "Process Name|Command Line")
for process in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process")._NewEnum()
    LV.Add("", process.Name, process.CommandLine)
Gui.Show
lexikos
Posts: 6657
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: [a104]: Object _Enum error

19 Aug 2019, 03:43

This is a separate issue. Given that you have posted about it in a topic which was already marked as solved, I could have easily missed it.

ComObjects translate __Enum to _NewEnum. The problem is that __Enum accepts a parameter, while _NewEnum does not (although it is possible that some COM objects will ignore it). It will be fixed.
User avatar
Maestr0
Posts: 81
Joined: 05 Dec 2013, 17:43

Re: [a104]: Object _Enum error

19 Aug 2019, 04:24

lexikos wrote:
19 Aug 2019, 03:43
This is a separate issue. Given that you have posted about it in a topic which was already marked as solved, I could have easily missed it.

ComObjects translate __Enum to _NewEnum. The problem is that __Enum accepts a parameter, while _NewEnum does not (although it is possible that some COM objects will ignore it). It will be fixed.
My bad. I will endeavour to do better in the future. Thank you.

Return to “AutoHotkey v2 Development”

Who is online

Users browsing this forum: No registered users and 6 guests