qsek Posted December 27, 2018 Share Posted December 27, 2018 (edited) Im not sure if this is intended but normally Autoit variables are always passed as copies (except objects i think). But below i observed an unconsistency when copying maps with nested maps inside. Issue: If you create a nested map1 and copy it to a new map2, changing a nested value in map2 will also change the nested value in map1 Dim $player[] Dim $sub[] $player.test1 = 1 $player.test2 = $sub $player.test2.child1 = "org" $player.test2.childext = $sub $player.test2.childext.child1 = "org2" $playerold = $player ; make a copy of the whole map ConsoleWrite("player.test2.child1 : "& $player.test2.child1 & @CRLF); original nested value in $player $playerold.test2.child1 = "changed" ; edit a nested value in $playerold ConsoleWrite("player.test2.child1 : "& $player.test2.child1 & @CRLF) ; original nested value in $player changed ConsoleWrite("---------------------" & @CRLF) ConsoleWrite("player.test2.childext.child1 : "& $player.test2.childext.child1 & @CRLF); original level2 nested value in $player $playerold.test2.childext.child1 = "changed2" ; edit a level2 nested value in $playerold ConsoleWrite("player.test2.child1 : "& $player.test2.child1 & @CRLF); original level1 nested value in $player stayed the same ConsoleWrite("player.test2.childext.child1 : "& $player.test2.childext.child1 & @CRLF); original level2 nested value in $player changed Edited December 27, 2018 by qsek Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite Link to comment Share on other sites More sharing options...
Developers Jos Posted December 27, 2018 Developers Share Posted December 27, 2018 Moved to the appropriate forum. Moderation Team SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
jchd Posted December 27, 2018 Share Posted December 27, 2018 That's how Map behaved. I used the past since it appears the implementation has a number of issues which precludes general public consumption. Future will tell if they reappear in release versions but for now don't rely on beta Maps for serious apps. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
spudw2k Posted December 28, 2018 Share Posted December 28, 2018 (edited) @qsek I just tried playing around with scripting dictionaries as they have similar uses, and they seem to behave the same way (although I could not get it to add a key/value pair to the nested, nested dictionary); updates to the nested dict updated the original. #include <Array.au3> Local $oPlayer = _DictionaryCreate() Local $oSub = _DictionaryCreate() $oPlayer.Add("test1", 1) $oPlayer.Add("test2", $oSub) $oPlayer("test2").Add("child1", "org") $oPlayer("test2").Add("childext", $oSub) ;~ $oPlayer("test2").("childext").Add("child1", "org2") Local $aItems = $oPlayer.Items _ArrayDisplay($aItems,"oPlayer") $aItems = $oPlayer.Item("test2").Items _ArrayDisplay($aItems,"oPlayer.test2") $oPlayer.Item("test2").Item("child1") = "childchanged" $aItems = $oSub.Items _ArrayDisplay($aItems,"oSub") Func _DictionaryCreate() Local $oDict = ObjCreate("Scripting.Dictionary") If @error Then Return SetError(@error, 0, 0) Return $oDict EndFunc Edited December 28, 2018 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
qsek Posted December 28, 2018 Author Share Posted December 28, 2018 @spudw2k not really the same. As expected because it is an object that will execute Methods on its own and give the data to the parent. That is also why you cannot add the 2nd level "child1" in $oPlayer.Item("test2").Item("childext").Add("child1", "org2") Because you already added it one level higher before to the same $oSub: $oPlayer.Item("test2").Add("child1", "org") Essentially what you are doing is $oPlayer.Item("test2").{ $oSub.Add("child1", "org") } $oPlayer.Item("test2").Item("childext").{ $oSub.Add("child1", "org") } Also your $oSub on its own fills with items as you use it with $oPlayer as parent. My Map $sub on the other hand will not fill with items. It is empty if you look at it after filling it with data with $player as parent. So internally it will create a new Map everytime you assign a submap like so. $player.test2 = $sub and also when creating a second version on a deeper level in one parentmap. I think this is intended as you dont have a ObjCreate with Maps. However if the whole map is copied, it creates references of the individual submaps in the copied one, which i think is not intended. Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite Link to comment Share on other sites More sharing options...
spudw2k Posted December 28, 2018 Share Posted December 28, 2018 Ah, I see. Thank you for taking the time to explain the behavior difference. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
qsek Posted December 28, 2018 Author Share Posted December 28, 2018 (edited) After some trying i found a workaround: Dim $player[] Dim $sub[] $player.test1 = 1 $player.test2 = $sub $player.test2.child1 = "org" $player.test2.childext = $sub $player.test2.childext.child1 = "org2" $player.a = $player ; make a temporary copy of the whole map inside an unused key of the map to be copied. ; This also forces the submaps to get their unique copies and all references to 'root' $player are cut. $playerold = $player.a ; So $playerold will recieve a independent copy of $player MapRemove($player, "a") ; Temporary copy not needed any more ConsoleWrite("player.test2.child1 : "& $player.test2.child1 & @CRLF); original nested value in $player $playerold.test2.child1 = "changed" ; edit a nested value in $playerold ConsoleWrite("player.test2.child1 : "& $player.test2.child1 & @CRLF) ; original nested value in $player changed ConsoleWrite("---------------------" & @CRLF) ConsoleWrite("player.test2.childext.child1 : "& $player.test2.childext.child1 & @CRLF); original level2 nested value in $player $playerold.test2.childext.child1 = "changed2" ; edit a level2 nested value in $playerold ConsoleWrite("player.test2.child1 : "& $player.test2.child1 & @CRLF); original level1 nested value in $player stayed the same ConsoleWrite("player.test2.childext.child1 : "& $player.test2.childext.child1 & @CRLF); original level2 nested value in $player changed Edited December 28, 2018 by qsek argumentum 1 Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite 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