Jump to content
qsek

Possible Maps Bug #2 - (Moved)

Recommended Posts

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 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

Share this post


Link to post
Share on other sites

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 here
RegExp tutorial: enough to get started
PCRE 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)

Share this post


Link to post
Share on other sites

@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 by spudw2k

Share this post


Link to post
Share on other sites

@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

Share this post


Link to post
Share on other sites

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 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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By BetaLeaf
      What is Rollbar?
      Rollbar provides real-time error alerting & debugging tools for developers. Learn more about it at https://rollbar.com/product/
      Demo: https://rollbar.com/demo/demo/
      Screenshot:
      Instructions: (RollbarTest.au3)
      ; Include RollbarSDK #include "RollbarSDK.au3" ;Turns on ConsoleWrite debugging override. ;Global $Rollbar_Debug=False ; Initialize RollbarSDK with the project's API key. ; Parameters ....: $__Rollbar_sToken - [Required] Go to https://rollbar.com/<User>/<ProjectName>/settings/access_tokens/ for your project. Use the token for post_server_item. _Rollbar_Init("eaa8464a4082eeabd9454465b8f0c0af") ; Write code that causes an error you want to catch, then call ; _Rollbar_Send ; Parameters ....: $__Rollbar_sErrorLevel - [Required] Must be one of the following values: Debug, Info, Warning, Error, Critical. ; $__Rollbar_sMessage - [Required] The message to be sent. This should contain any useful debugging info that will help you debug. ; $__Rollbar_sMessageSummary - [Optional] A string that will be used as the title of the Item occurrences will be grouped into. Max length 255 characters. If omitted, Rollbar will determine this on the backend. _Rollbar_Send("Debug", "This is an debug message. If you received this, you were successful!", "Debug Message") _Rollbar_Send("Info", "This is a test message. If you received this, you were successful!", "Info Message") _Rollbar_Send("Warning", "This is an warning message. If you received this, you were successful!", "Warning Message") _Rollbar_Send("Error", "This is an error message. If you received this, you were successful!", "Error Message") _Rollbar_Send("Critical", "This is an critical message. If you received this, you were successful!", "Critical Message") _Rollbar_Send("Info", "This is a test message. If you received this, you were successful!") ;No Message ; Rollbar_Send's helper functions ; Parameters ....: $__Rollbar_sMessage - [Required] The message to be sent. This should contain any useful debugging info that will help you debug. ; $__Rollbar_sMessageSummary - [Optional] A string that will be used as the title of the Item occurrences will be grouped into. Max length 255 characters. If omitted, Rollbar will determine this on the backend. _Rollbar_SendDebug("This is an debug message. If you received this, you were successful!", "Debug Message") _Rollbar_SendInfo("This is a test message. If you received this, you were successful!", "Info Message") _Rollbar_SendWarning("This is an warning message. If you received this, you were successful!", "Warning Message") _Rollbar_SendError("This is an error message. If you received this, you were successful!", "Error Message") _Rollbar_SendCritical("This is an critical message. If you received this, you were successful!", "Critical Message") ; Usable Example Local $sImportantFile = "C:\NOTAREALFILE_1234554321.txt" Switch FileExists($sImportantFile) Case True MsgBox(0, "Example Script", "An important file was found. Continuing...") Case Else _Rollbar_SendCritical('An important file was missing. Halting... File: "' & $sImportantFile & '"', 'Important file "' & $sImportantFile & '" is missing.') EndSwitch Notes: Please comment your feedback, advice, & suggestions below. While this is only a proof of concept, I will expand its feature set for everyone to use. 
      Right now, it is fully functional but not tested in production.
       
       
      Changelog:
      RollbarSDK.au3
      RollbarTest.au3
      v0.2
       
      v0.1.1
       
    • By BetaLeaf
      As the title says, when a script that is stored on a Google Drive File Stream drive is ran or compiled, it fails to work at all.
      Basically, Google Drive File Stream creates a G:\ drive where you can access all your files. The difference between this and Google Backup and Sync is your files are downloaded as needed rather than they always be downloaded and taking up storage. 
      How to Reproduce Bug
      1. Download and Install Google Drive File Stream
      2. Sign into Google Drive File Stream with a G Suite account. 
      3. Create a AutoIt Script and save it to Google Drive File Stream. (See attached file)
      4. Attempt to run or compile this AutoIt Script. 
       
      AutoIt appears to act like the script is (incorrectly) empty and ends immediately. (You can kind of tell based on file sizes from a successful and failed compile).
      I've also attached a Process Monitor log file. Hopefully someone can figure this out, because having to move the script out of the drive just to run or compile it is super annoying and I lose version revisioning Google Drive provides me.
      test.au3
      Logfile.PML
    • By kara2004
      Hi there,
      I have a problem using the latest two betas of au3stripper.exe.
      Compiling my script using V17.224.935.6 works fine, the next two releases (18.624.1847.0 and 18.624.1847.1) show an error:
      !==> *** ERROR: stopping process because include file not found :#include <INCLUDE_FILE.au3> !==> *** Checked these directories : !==> C:\Program Files (x86)\AutoIt3\include\INCLUDE_FILE.au3 !==> SCRIPT_DIR\INCLUDE_FILE.au3 !==> SCRIPT_DIR\INCLUDE_FILE.au3 !>18:42:00 --------------------------------------------------------------- !>18:42:00 Au3Stripper ended with errors, using original scriptfile.rc:999 !>18:42:00 --------------------------------------------------------------- Changing the include line according to the helpfile (using "..." for includes in script dir and <..> for includes in the au3-include-dir won't help!?
      Greetings
      kara66
       
    • By qsek
      Can somebody try to reproduce this bug?
      It would be helpful to know if this issue appeares on other environments too.
      Issue:
      Sometimes values of certain keys will return empty even if expicitly assigned a value before.
      Conditions:
      Map is bigger than ~50 key/values pairs value is being worked with in a Function where a loop is iterating through the Map before retrieving the value there is a isMap/MapKeys/MapAppend/MapRemove check on the Map value. Dim $mMap[] ; Generate random key strings For $i = 0 To 100 $RndKey = "" For $i2 = 0 To 4 $RndKey &= Chr(Random(65,90,1)) Next $mMap[$RndKey] = 999 next ConsoleWrite("-----------1-------------" & @CRLF); Unpredictable blank values MapDisplay1($mMap) ConsoleWrite("-----------2-------------" & @CRLF); ByRef always works MapDisplay2($mMap) ConsoleWrite("-----------3-------------" & @CRLF); not in a function always works For $i In MapKeys($mMap) isMap($mMap[$i]) ConsoleWrite($i&": "&$mMap[$i]&@CRLF) Next Func MapDisplay1( $m_Map ) For $i In MapKeys($m_Map) isMap($m_Map[$i]) ;same problem with isMap($m_Map[$i]), MapKeys($m_Map[$i]), MapAppend/MapRemove but NOT with MapExists($m_Map,$i) ConsoleWrite($i&": "&$m_Map[$i]&@CRLF) Next EndFunc Func MapDisplay2( ByRef $m_Map ) For $i In MapKeys($m_Map) isMap($m_Map[$i]) ConsoleWrite($i&": "&$m_Map[$i]&@CRLF) Next EndFunc  
      The value is not lost or overwritten on the global map, only on the local map inside the function.
       
×
×
  • Create New...