Gabriel13 Posted October 17, 2009 Posted October 17, 2009 While debugging my JSON library, I've run into a situation where working with a Scripting.Dictionary object results in my boolean values being changed into numbers.func testDictionary($a) local $d=objCreate('Scripting.Dictionary') for $i=0 to ubound($a)-1 $d.add($i,$a[$i]) next return $d endfunc local $aTest[2]=[false,true] msgbox(0,default,$aTest[0]) ; displays false msgbox(0,default,$aTest[1]) ; displays true local $ignore=testDictionary($aTest) msgbox(0,default,$aTest[0]) ; now displays 0 instead of false msgbox(0,default,$aTest[1]) ; now displays 1 instead of trueApparently, by just referencing the boolean values in the $d.add() call, they're converted into numbers within my array.The only way I've found to avoid this problem is to make sure I have an immutable reference to my variables – in this case, by changing the top line to:func testDictionary(const byRef $a) [url='http://www.autoitscript.com/forum/index.php?showtopic=104150']JSON UDF Library (fully RFC4627-compliant)[/url][url='http://www.autoitscript.com/forum/index.php?showtopic=104325']Keep Windows Clear of Top Taskbar (for those who like their taskbar on top)[/url]
BugFix Posted October 17, 2009 Posted October 17, 2009 I think, it's not a problem because AutoIt treats 0 even like FALSE and 1 like TRUE. Best Regards BugFix
Gabriel13 Posted October 17, 2009 Author Posted October 17, 2009 It's a bit surprising that a COM object can mutate my variable types just by "looking" at them like this. This was nowhere on my radar screen when looking for bugs, and introduces another potential set of unexpected side-effects to watch out for. Also, when dealing with JSON data, the distinction between "0" and "false" can indeed be significant. That being said, I'm sure your explanation covers why this particular scenario may have gone unnoticed until now. [url='http://www.autoitscript.com/forum/index.php?showtopic=104150']JSON UDF Library (fully RFC4627-compliant)[/url][url='http://www.autoitscript.com/forum/index.php?showtopic=104325']Keep Windows Clear of Top Taskbar (for those who like their taskbar on top)[/url]
Gabriel13 Posted October 18, 2009 Author Posted October 18, 2009 Opened a ticket for this issue: #1234(…that's amazing, I've got the same combination on my luggage!) [url='http://www.autoitscript.com/forum/index.php?showtopic=104150']JSON UDF Library (fully RFC4627-compliant)[/url][url='http://www.autoitscript.com/forum/index.php?showtopic=104325']Keep Windows Clear of Top Taskbar (for those who like their taskbar on top)[/url]
AdmiralAlkex Posted October 18, 2009 Posted October 18, 2009 (…that's amazing, I've got the same combination on my luggage!)I love that movie... But they said 12345 .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
Gabriel13 Posted October 18, 2009 Author Posted October 18, 2009 I love that movie... But they said 12345 Details, details… In related news, a recent phishing attack revealed that '12345' was the most popular phished Hotmail password. Apparently President Skroob uses Hotmail! [url='http://www.autoitscript.com/forum/index.php?showtopic=104150']JSON UDF Library (fully RFC4627-compliant)[/url][url='http://www.autoitscript.com/forum/index.php?showtopic=104325']Keep Windows Clear of Top Taskbar (for those who like their taskbar on top)[/url]
AdmiralAlkex Posted October 18, 2009 Posted October 18, 2009 Details, details… In related news, a recent phishing attack revealed that '12345' was the most popular phished Hotmail password. Apparently President Skroob uses Hotmail! It's nice seeing Skroob is still alive after crashing on the "Planet of the Apes" (I wonder how the apes got internet though ) .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
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