Ranmaru Posted July 25, 2007 Share Posted July 25, 2007 C:\Documents and Settings\Ranmaru\Työpöytä\AutoIt\TCPIP\test\ranserver.au3 (127) : ==> Variable must be of type "Object".: For $con In $conlist For $con In $conlist^ ERROR >Exit code: 1 Time: 2.052 $conlist is declared here which is at the start of the code. Global $conlist = ObjCreate("Scripting.Dictionary") I've used two other scripting dictionaries in this script and they've both worked fine, but for some reason this doesn't? Link to comment Share on other sites More sharing options...
Zedna Posted July 25, 2007 Share Posted July 25, 2007 Add COM error handler to your script: $objErr = ObjEvent("AutoIt.Error","MyErrFunc") Func MyErrFunc() $hexnum=hex($objErr.number,8) Msgbox(0,"","We intercepted a COM Error!!" & @CRLF & @CRLF & _ "err.description is: " & $objErr.description & @CRLF & _ "err.windescription is: " & $objErr.windescription & @CRLF & _ "err.lastdllerror is: " & $objErr.lastdllerror & @CRLF & _ "err.scriptline is: " & $objErr.scriptline & @CRLF & _ "err.number is: " & $hexnum & @CRLF & _ "err.source is: " & $objErr.source & @CRLF & _ "err.helpfile is: " & $objErr.helpfile & @CRLF & _ "err.helpcontext is: " & $objErr.helpcontext _ ) Exit ; SetError(1) EndFunc Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Ranmaru Posted July 25, 2007 Author Share Posted July 25, 2007 Ok so I did and here's the result.We intercepted a COM Error!!err.description is: err.windescription is: Variable is not of type 'Object'.err.lastdllerror is: 0err.scriptline is: 129err.number is: 000000A9err.source is: err.helpfile is: err.helpcontext is: Link to comment Share on other sites More sharing options...
lordofthestrings Posted July 26, 2007 Share Posted July 26, 2007 $conlist = ObjCreate("Scripting.Dictionary") $conlist2 = ObjCreate("Scripting.Dictionary") $conlist3 = ObjCreate("Scripting.Dictionary") $conlist4 = ObjCreate("Scripting.Dictionary") $conlist.Add("Printer list 1 1", "Printing") $conlist.Add("Printer list 1 2", "Offline") $conlist.Add("Printer list 1 3", "Printing") $conlist.Count ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $conlist.Count = ' & $conlist.Count & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console $conlist2.Add("Printer list 2 1", "Printing") $conlist2.Add("Printer list 2 2", "Offline") $conlist2.Add("Printer list 2 3", "Printing") $conlist2.Count ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $conlist2.Count = ' & $conlist2.Count & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console $conlist3.Add("Printer list 3 1", "Printing") $conlist3.Add("Printer list 3 2", "Offline") $conlist3.Add("Printer list 3 3", "Printing") $conlist3.Count ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $conlist3.Count = ' & $conlist3.Count & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console $conlist4.Add("Printer list 4 1", "Printing") $conlist4.Add("Printer list 4 2", "Offline") $conlist4.Add("Printer list 4 3", "Printing") $conlist4.Count ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $conlist4.Count = ' & $conlist4.Count & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console Link to comment Share on other sites More sharing options...
lordofthestrings Posted July 26, 2007 Share Posted July 26, 2007 I think the problem with this vb script conversion of yours is that you try to globally declare the variable, and on the fly try to insert the reference to the object (objcreate). there if you put a debug msgbox you should see that the returned value is not what it is supposed to be.. try globally declaring your variables on top of your script Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 26, 2007 Share Posted July 26, 2007 C:\Documents and Settings\Ranmaru\Työpöytä\AutoIt\TCPIP\test\ranserver.au3 (127) : ==> Variable must be of type "Object".: For $con In $conlist For $con In $conlist^ ERROR >Exit code: 1 Time: 2.052 $conlist is declared here which is at the start of the code. Global $conlist = ObjCreate("Scripting.Dictionary") I've used two other scripting dictionaries in this script and they've both worked fine, but for some reason this doesn't? This is not enough information to duplicate the symptoms. No "reproducer", as Dale Hohm would call it. The following works fine: #include <array.au3> Global $conlist = ObjCreate("Scripting.Dictionary") $conlist.Add ("Printer list 1 1", "Printing") $conlist.Add ("Printer list 1 2", "Offline") $conlist.Add ("Printer list 1 3", "Printing") $i = 0 For $con In $conlist ConsoleWrite("Item " & $i & " out of " & $conlist.count & ": " & $con & @LF) $i += 1 Next $avItems = $conlist.Items _ArrayDisplay($avItems, "Debug: $avItems") $avKeys = $conlist.Keys _ArrayDisplay($avKeys, "Debug: $avKeys") What more do you have to do to it to replicate your symptoms? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Ranmaru Posted July 26, 2007 Author Share Posted July 26, 2007 Ah sorry about that. There was a gui object handle with the same variable name. Fixed that. :"> Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 26, 2007 Share Posted July 26, 2007 Ah sorry about that. There was a gui object handle with the same variable name. Fixed that. :"> [sarcasm] Well, as one who has NEVER posted anything wrong, stupid, or confused on this forum, I guess I'll let that pass... [/sarcasm] Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
cornernote Posted June 26, 2009 Share Posted June 26, 2009 #include <array.au3> Global $conlist = ObjCreate("Scripting.Dictionary") $conlist.Add ("Printer list 1 1", "Printing") $conlist.Add ("Printer list 1 2", "Offline") $conlist.Add ("Printer list 1 3", "Printing") $i = 0 For $con In $conlist ConsoleWrite("Item " & $i & " out of " & $conlist.count & ": " & $con & @LF) $i += 1 Next $avItems = $conlist.Items _ArrayDisplay($avItems, "Debug: $avItems") $avKeys = $conlist.Keys _ArrayDisplay($avKeys, "Debug: $avKeys") gives me this error: >"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "\\BRETT-PC-XP\SharedDocs\test.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams +>10:26:06 Starting AutoIt3Wrapper v.1.10.1.14 Environment(Language:0409 Keyboard:00000409 OS:WIN_XP/Service Pack 2 CPU:X86 ANSI) >Running AU3Check (1.54.14.0) from:C:\Program Files\AutoIt3 +>10:26:07 AU3Check ended.rc:0 >Running:(3.3.0.0):C:\Program Files\AutoIt3\autoit3.exe "\\BRETT-PC-XP\SharedDocs\test.au3" \\BRETT-PC-XP\SharedDocs\test.au3 (5) : ==> Variable must be of type "Object".: $conlist.Add ("Printer list 1 1", "Printing") $conlist^ ERROR ->10:26:08 AutoIT3.exe ended.rc:1 +>10:26:09 AutoIt3Wrapper Finished >Exit code: 1 Time: 3.644 Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 26, 2009 Share Posted June 26, 2009 (edited) gives me this error: >"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "\\BRETT-PC-XP\SharedDocs\test.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams +>10:26:06 Starting AutoIt3Wrapper v.1.10.1.14 Environment(Language:0409 Keyboard:00000409 OS:WIN_XP/Service Pack 2 CPU:X86 ANSI) >Running AU3Check (1.54.14.0) from:C:\Program Files\AutoIt3 +>10:26:07 AU3Check ended.rc:0 >Running:(3.3.0.0):C:\Program Files\AutoIt3\autoit3.exe "\\BRETT-PC-XP\SharedDocs\test.au3" \\BRETT-PC-XP\SharedDocs\test.au3 (5) : ==> Variable must be of type "Object".: $conlist.Add ("Printer list 1 1", "Printing") $conlist^ ERROR ->10:26:08 AutoIT3.exe ended.rc:1 +>10:26:09 AutoIt3Wrapper Finished >Exit code: 1 Time: 3.644 Still works fine for me on XP SP2. Try adding a COM error handler to see if it will tell you why you could create the object. Edit: Fell for the old double post... Edited June 26, 2009 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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