Modify

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#1293 closed Bug (No Bug)

odd value returned when assigning "default" to Scripting.Dictionary

Reported by: Gabriel13 Owned by:
Milestone: Component: AutoIt
Version: 3.3.0.0 Severity: None
Keywords: Cc:

Description

When the AutoIt "default" value is assigned to a Scripting.Dictionary object, and later retrieved, the result is no longer "default".

Instead, it becomes a strange "falsy" value which varGetType() identifies as "Object", yet it fails the isObj() test.

The code below illustrates what happens - I've also confirmed that this issue is present in the latest beta (3.3.1.5).

func testDictionary($v)
	local $d=objCreate('Scripting.Dictionary')
	$d.add('x',$v)
	return $d.item('x')
endfunc

msgbox(0,default,@AutoItVersion)

local $v=default
msgbox(0,default,'"' & string($v) & '"' & @LF & varGetType($v) & @LF & isObj($v))
; returns "Default", Keyword, 0

; assign to dictionary & then retrieve
$v=testDictionary($v)
msgbox(0,default,'"' & string($v) & '"' & @LF & varGetType($v) & @LF & isObj($v))
; returns "", Object, 0

if $v then
	msgbox(0,default,'truey')
else
	msgbox(0,default,'falsy')
endif
; returns "falsy"

Attachments (0)

Change History (4)

comment:1 Changed 14 years ago by Valik

  • Resolution set to No Bug
  • Status changed from new to closed

Um, okay. I'm not sure how you expect an AutoIt-specific keyword to be stored and preserved in an external object. This is certainly not a bug.

comment:2 Changed 14 years ago by Gabriel13

My intention was to illustrate the contradictory nature of the returned value, which seems to indicate a bug of some kind.

comment:3 Changed 14 years ago by Valik

But there's no bug here. Default is an AutoIt keyword that has a special meaning in the context of COM. It is not, however, data that can be marshaled through a COM object or a C-like (Dll) API. In the context of COM the Default keyword behaves more or less like it does in AutoIt. That is, it tells the function to treat that parameter as being undefined and to use whatever internal value it wants to. You can likely reproduce the same behavior in VBS by using it's "Default" convention (I don't know what it is, I don't use VBS). However, even though it works in COM in a similar fashion to AutoIt, there is a translation that occurs before going to the COM object.

comment:4 Changed 14 years ago by Gabriel13

Aha, I understand now - the Scripting.Dictionary COM object is responsible for how its methods define the "default" value for each parameter. So the value it assigns to the dictionary, as a result of calling its Add() method with "Default", is outside the control of AutoIt.

Thanks for taking the time to explain this, I appreciate it!

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.