Page 1 of 1

[a104]: Object _Enum error

Posted: 17 Aug 2019, 19:18
by aseiot
Following code cause script error:
Error: Type mismatch
Specifically: _Enum

Code: Select all

for k, v in {A : 1, B : 2}
{
	MsgBox k ":" v
}

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

Posted: 17 Aug 2019, 19:30
by aseiot
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
}
:?

Re: [a104]: Object _Enum error

Posted: 18 Aug 2019, 03:18
by Helgef
or for k, v in map('A', 1, 'B', 2)

Cheers.

Re: [a104]: Object _Enum error

Posted: 18 Aug 2019, 04:09
by Maestr0
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

Re: [a104]: Object _Enum error

Posted: 19 Aug 2019, 03:43
by lexikos
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.

Re: [a104]: Object _Enum error

Posted: 19 Aug 2019, 04:24
by Maestr0
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.