JohnOne Posted September 22, 2015 Share Posted September 22, 2015 (edited) That could be tested by assigning the array to null and trying to access the dictionary instance..EDIT: looks like a copy is made.$myDictionary = _MapInit() ;map add key/value pairs _MapAddKeyValuePair($myDictionary , "KeyEntry0" , "ValueEntry0") ; adding key/value pairs _MapAddKeyValuePair($myDictionary , "KeyEntry1" , "ValueEntry1") _MapAddKeyValuePair($myDictionary , "KeyEntry2" , "ValueEntry2") local $aTestarray[2] $aTestarray[0] = "ValueEntry3-1" $aTestarray[1] = "ValueEntry3-2" _MapAddKeyValuePair($myDictionary , "KeyEntry3" , $aTestarray) $aTestarray = null For $value in $myDictionary.Item("KeyEntry3") consolewrite($value & @LF) NextWorks just fine. Edited September 22, 2015 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
iamtheky Posted September 22, 2015 Author Share Posted September 22, 2015 Is this the best manner in which to unpack a dictionary with both strings and arrays? I'm thinking now that specifying a duplicate key should give the option to make an array of values rather than fail or append to the string.For $Key in $myDictionary If IsArray($myDictionary.Item($Key)) Then For $value in $myDictionary.Item($Key) consolewrite($Key & "=" & $value & @LF) Next Else consolewrite($key & "=" & $myDictionary.Item($Key) & @LF) EndIf Next ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
LarsJ Posted September 23, 2015 Share Posted September 23, 2015 JohnOne, It seems to be a copy. Thank you for the test. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
iamtheky Posted September 23, 2015 Author Share Posted September 23, 2015 (edited) Avoiding a large array copy, you can drop a dictionary in your dictionary... Creating a UDF that would allow for the storage and unpacking of all types of data would be a bitch.#include 'dictmap.au3' local $mDictMaster = _MapInit() local $mDict2 = _MapInit() _MapAddKeyValuePair($mDict2 , "SubKeyEntry1" , "ValueEntry1") ; adding key/value pairs to Dict2 _MapAddKeyValuePair($mDict2 , "SubKeyEntry2" , "ValueEntry2") _MapAddKeyValuePair($mDict2 , "SubKeyEntry3" , "ValueEntry3") _MapAddKeyValuePair($mDictMaster , "MasterKey1" , $mDict2) ; add Dict2 to the Master Dictionary For $entry in $mDictMaster.Item("MasterKey1") msgbox(0, '' , $entry & " = " & $mDictMaster.Item("MasterKey1").item($entry)) Next Edited September 23, 2015 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
iamtheky Posted September 25, 2015 Author Share Posted September 25, 2015 dictionary in dictionary is interesting me more. Here is a better example with languages:#include 'dictmap.au3' local $mDictMaster = _MapInit() local $mEspanol = _MapInit() local $mDeutsch = _MapInit() _MapAddKeyValuePair($mEspanol , "Horse" , "Caballo") ; adding key/value pairs to Spanish Dict _MapAddKeyValuePair($mEspanol , "Cow" , "Baca") _MapAddKeyValuePair($mEspanol , "Chicken" , "Pollo") _MapAddKeyValuePair($mDeutsch , "Horse" , "Pferd") ; adding key/value pairs to German Dict _MapAddKeyValuePair($mDeutsch , "Cow" , "Kuh") _MapAddKeyValuePair($mDeutsch , "Chicken" , "Huhn") _MapAddKeyValuePair($mDictMaster , "Spanish" , $mEspanol) ; add Spanish _MapAddKeyValuePair($mDictMaster , "German" , $mDeutsch) ; add German msgbox(0, '' , $mDictMaster.Item("Spanish").item("Cow")) msgbox(0, '' , $mDictMaster.Item("German").item("Chicken")) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
trancexx Posted September 25, 2015 Share Posted September 25, 2015 ^^You should be able to call it like this too (.item is default prop/method):Msgbox(0, '' , $mDictMaster("German")("Chicken"))...Tho Au3Check isn't maintained properly and doesn't follow AutoIt correctly which is why you should disable it before running such code. iamtheky 1 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
iamtheky Posted September 30, 2015 Author Share Posted September 30, 2015 (edited) using that format, to build a lookup that takes the word and returns the language. expandcollapse popup#include 'dictmap.au3' #AutoIt3Wrapper_Run_Au3Check = 0 local $mDictMaster = _MapInit() local $mEspanol = _MapInit() local $mDeutsch = _MapInit() _MapAddKeyValuePair($mEspanol , "Horse" , "Caballo") ; adding key/value pairs to Spanish Dict _MapAddKeyValuePair($mEspanol , "Cow" , "Baca") _MapAddKeyValuePair($mEspanol , "Chicken" , "Pollo") _MapAddKeyValuePair($mDeutsch , "Horse" , "Pferd") ; adding key/value pairs to German Dict _MapAddKeyValuePair($mDeutsch , "Cow" , "Kuh") _MapAddKeyValuePair($mDeutsch , "Chicken" , "Huhn") _MapAddKeyValuePair($mDictMaster , "Spanish" , $mEspanol) ; add Spanish _MapAddKeyValuePair($mDictMaster , "German" , $mDeutsch) ; add German msgbox(0, '' , _CheckLanguage("Pollo")) msgbox(0, '' , _CheckLanguage("Kuh")) msgbox(0, '' , _CheckLanguage("Horse")) msgbox(0, '' , _CheckLanguage("Xhiken")) Func _CheckLanguage($sString) For $key in $mDictMaster For $entry in $mDictMaster($key) If stringinstr($sString , $entry) Then return "English" If stringinstr($sString , $mDictMaster($key)($entry)) Then return $key Next Next return "'" & $sString & "'" & " Was Not Found" EndFunc Edited October 2, 2015 by boththose better ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) 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