susall Posted July 14, 2009 Posted July 14, 2009 I'm trying to understand the error message I'm getting back from AutoIT when I try to run this line of code: C:\Documents and Settings\llewels\Desktop\AutoITScripts\ConfigCases.au3 (63) : ==> Variable must be of type "Object".: $filename = $oDict.Item("Resultpath") & "\" & $frontdate & "_" & $caseID & "_" & $date & "_results.xml" The variable $oDict is already set to the Scripting.Dictionary object. If the Item property returns an object, how would I declare $filename in AutoIT? I'm running version 3.3.0.0. I've looked at other similar posts and they don't seem to solve this problem, either. -su
susall Posted July 14, 2009 Author Posted July 14, 2009 When I try it this way: Dim $tmp = "Resultpath" & "\" & $frontdate & "_" & $caseID & "_" & $date & "_results.xml" $filename = $oDict.Item(tmp) I see it's treating Item as a keyword of AutoIT, when it's a property of the Scripting.Dictionary object.
zfisherdrums Posted July 14, 2009 Posted July 14, 2009 When I try it this way: Dim $tmp = "Resultpath" & "\" & $frontdate & "_" & $caseID & "_" & $date & "_results.xml" $filename = $oDict.Item(tmp) I see it's treating Item as a keyword of AutoIT, when it's a property of the Scripting.Dictionary object. The example above does not appear to be equivalent to what was written in the original post. Perhaps I'm missing some details, but does this resolve the issue? Dim $tmp = "Resultpath" & "\" & $frontdate & "_" & $caseID & "_" & $date & "_results.xml" $filename = $oDict(tmp) Identify .NET controls by their design time namesLazyReader© could have read all this for you. Unit Testing for AutoItFolder WatcherWord Doc ComparisonThis here blog...
susall Posted July 22, 2009 Author Posted July 22, 2009 The example above does not appear to be equivalent to what was written in the original post. Perhaps I'm missing some details, but does this resolve the issue? Dim $tmp = "Resultpath" & "\" & $frontdate & "_" & $caseID & "_" & $date & "_results.xml" $filename = $oDict(tmp) You're right... I was trying to get down to the bottom of why Scripting Dictionary doesn't work. I haven't solved it yet. But the Item member of Dictionary object is color-coded by the Script-Editor as though it was an AutoIT keyword. -su
MilesAhead Posted July 22, 2009 Posted July 22, 2009 (edited) You could try these wrapper functions #include <Array.au3> Func _AssocArray() Local $aArray = ObjCreate("Scripting.Dictionary") If @error Then Return SetError(1, 0, 0) EndIf $aArray.CompareMode = 1 Return $aArray EndFunc ;==>_AssocArray Func _AssocArrayDestroy(ByRef $aArray) If Not IsObj($aArray) Then Return False EndIf $aArray.RemoveAll() $aArray = 0 Return True EndFunc ;==>_AssocArrayDestroy The Item property is the default so don't even state it. Use something like this: $aArray = _AssocArray() $aArray("ResultPath") = "C:\SomePath" $path = $aArray("ResultPath") & "\yaddayadda" ;when done destroy array _AssocArrayDestroy($aArray) Edited July 22, 2009 by MilesAhead My Freeware Page
Xand3r Posted July 22, 2009 Posted July 22, 2009 wrappers or not Variable must be of type "Object".: $filename = $oDict.Item("Resultpath") means that $oDict is not an object and therefore does not contain a dictionary object $oDict=ObjCreate("Scripting.Dictionary") $oDict.Item("Resultpath")='C:\SomePath' MsgBox(0 , "Test" , $oDict("Resultpath")) Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro
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