Lazycat Posted June 23, 2005 Share Posted June 23, 2005 Not had many experience with COM, so maybe I just miss something. Instead it looks like a bug. I'm tried to assign value to object property with the Assign function, but seems this work not as I expect. Before assigning Eval get right property value. But after assigning I see that actual object property value not changed, but if I try get it by name via Eval, it show value that I assign! So this looks like Assign create some new variable instead assign value to existing property. Here is simple example for this (based on the standard example): #include <GUIConstants.au3> $oForm = ObjCreate("Forms.Form.1") $oForm.caption = "Forms Frame Test"; OK! $oButton=$oForm.Add("Forms.CommandButton.1","TestButton",1) With $oButton .caption="Test Button" .Left=10 .Top=8 .Height=20 .Visible=1 EndWith $oForm.repaint MsgBox (0, "Width returned by Eval", Eval("$oButton.Width")) Assign("$oButton.Width", 200) MsgBox (0, "Width after Assign", $oButton.Width) MsgBox (0, "Width after Assign via Eval", Eval("$oButton.Width")) GUICreate ("Embedded ActiveX Test", 640, 480) $GUI_ActiveX=GUICtrlCreateObj ( $oForm, 10, 10 , 400 , 400 ) $GUI_Label=GUICtrlCreateLabel ( "", 10, 420 , 300 , 20 ) GUISetState () While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
Lazycat Posted June 25, 2005 Author Share Posted June 25, 2005 No thoughts? I would post this in the bug report section, but I not sure if this bug or feature... Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
Valik Posted June 25, 2005 Share Posted June 25, 2005 Assign() doesn't even work with built-in AutoIt arrays, what do you think the odds are of it being able to assign to properties on COM objects? Link to comment Share on other sites More sharing options...
SvenP Posted June 27, 2005 Share Posted June 27, 2005 Not had many experience with COM, so maybe I just miss something. Instead it looks like a bug.I'm tried to assign value to object property with the Assign function, but seems this work not as I expect. Before assigning Eval get right property value. But after assigning I see that actual object property value not changed, but if I try get it by name via Eval, it show value that I assign! So this looks like Assign create some new variable instead assign value to existing property.Here is simple example for this (based on the standard example):... $GUI_EVENT_CLOSE Then ExitLoop Wend<{POST_SNAPBACK}>Lazycat,Assign and Eval only work with Variables. $oButton.Width is NOT a variable, but a COM property. However: Assign() does NOT check in any way if the "variable name" contains valid characters. You could say that this is a bug, because you could create @variables this way using: Assign("@error",200). Or even nastier: Assign("@oButton[Width].blah()", 200) is also being accepted.It's a nice way to 'hide' your variables: Set them using Assign, read them using Eval.But I guess we (the developers) will soon make an end to this kind of abuse ! :-)We will add a line to the AutoIt3 license: "Thy shall not abuse variable names"Regards,-Sven Link to comment Share on other sites More sharing options...
Lazycat Posted June 28, 2005 Author Share Posted June 28, 2005 Ok, understand. I was messed, because Eval() can get object properties and I presume that Assign also should work. Though for Eval you should include $ sign in string, so this looks suspicious... So for now I describe this as side effect. Handle with care Thanks all for explanation. Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now