lorenz Posted June 12, 2020 Share Posted June 12, 2020 hi all, I'm playing around with maps and mostly get them to do what I want 8-) But there is one point where I'm not sure if what I want to do is supposed to work or not, or if I'm doing something wrong. Local $map1[] Local $map2[] $map2.foo = 0 $map2.bar = $map1 $map2.bar.baz = "so far so good" MsgBox(0, "", $map2.bar.baz & @CRLF & $map2.bar["baz"]) $map2.bar["baz"] = 0 the last line should be equivalent to the line just before the message box. But after closing the box I get a runtime error --------------------------- AutoIt Error --------------------------- Line 11 (File "C:\Users\lenhardt\Desktop\AutoIt v3 Script (neu) (2).au3"): $map2.bar["baz"] = 0 $map2.bar["baz"] ^ ERROR Error: Variable must be of type "Object". --------------------------- Originally I tried $map2.bar[0] = 1 after that failed, I tried the other variants. So, is this a bug, or not supposed to work? Lorenz Link to comment Share on other sites More sharing options...
jchd Posted June 12, 2020 Share Posted June 12, 2020 You have a choice of syntaxes: Local $map1[] Local $map2[] $map1["what gives?"] = 4 $map2.foo = 5 $map2.bar = $map1 $map2.bar.baz = "so far so good" MsgBox(0, "", $map2.bar.baz & @CRLF & $map2.bar["baz"]) $map2.bar.baz = 3 $map2.bar.baz *= 3 $map2["bar"]["baz"] *= 10 $map2["bar"]["what gives?"] = -6 vd($map2) vd() is a homebrew variable dump which yields: Map[2] ['foo'] => Int32 5 ['bar'] => Map[2] ['what gives?'] => Int32 -6 ['baz'] => Int32 90 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...
lorenz Posted June 13, 2020 Author Share Posted June 13, 2020 Thanks. But that confirms my suspicion that their is still a "feature" here 8-) Because I don't think it's on purpose that $map2.bar["baz"] can be used to access the value of the entry, but not to assign a value to it. Lorenz Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 13, 2020 Moderators Share Posted June 13, 2020 lorenz, It does seem rather strange that only 1 of the 4 syntax options fails on assignment: #AutoIt3Wrapper_Run_AU3Check=n Local $map1[] Local $map2[] $map2.foo = 0 $map2.bar = $map1 $map2["bar"]["baz"] = "fred" MsgBox(0, "", $map2.bar.baz & @CRLF & $map2.bar["baz"] & @CRLF & $map2["bar"].baz & @CRLF & $map2["bar"]["baz"]) $map2.bar.baz = "dick" MsgBox(0, "", $map2.bar.baz & @CRLF & $map2.bar["baz"] & @CRLF & $map2["bar"].baz & @CRLF & $map2["bar"]["baz"]) $map2["bar"].baz = "dora" MsgBox(0, "", $map2.bar.baz & @CRLF & $map2.bar["baz"] & @CRLF & $map2["bar"].baz & @CRLF & $map2["bar"]["baz"]) $map2.bar["baz"] = "oops" MsgBox(0, "", $map2.bar.baz & @CRLF & $map2.bar["baz"] & @CRLF & $map2["bar"].baz & @CRLF & $map2["bar"]["baz"]) I will point Jon towards the thread. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
lorenz Posted June 13, 2020 Author Share Posted June 13, 2020 Aaaaannnd the next "feature" 8-) Global $mainMap[] Global $childMap[] $childMap[0] = "map0" Global $childArray[] = ["array0"] $mainMap.map = $childMap $mainMap.array = $childArray MsgBox(0, "", $mainMap.map[0] & @CRLF & $mainMap.array[0]) $mainMap["map"][0] = "works" $mainMap["array"][0] = "not" $mainMap.array[0] = "neither" sadly the solution for the sub-map problem does not work for a sub-array. Lorenz Link to comment Share on other sites More sharing options...
lorenz Posted June 13, 2020 Author Share Posted June 13, 2020 Don't get me wrong. I'm not complaining, the maps feature is still beta, just pointing out the problems I stumble upon while probing around Lorenz Link to comment Share on other sites More sharing options...
jchd Posted June 13, 2020 Share Posted June 13, 2020 That's one of the reason why I often recommend against nested arrays, maps or combinations thereof. 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...
jchd Posted June 13, 2020 Share Posted June 13, 2020 It looks like the square bracket syntax takes precedence over the dot syntax in the parser. 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...
Moderators Melba23 Posted June 13, 2020 Moderators Share Posted June 13, 2020 jchd, Quote That's one of the reason why I often recommend against nested arrays, maps or combinations thereof. I do it a lot - but I always extract the "inner" arrays/maps to a temporary variable before doing anything with them. And especially if I will be changing their content - after which I reassign them to their place in the "container". M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
jchd Posted June 13, 2020 Share Posted June 13, 2020 Yeah but it's clumsy. Often enough other data structures are more efficient and maintainable. Yet there are contexts where such structures are beneficial. 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...
lorenz Posted June 14, 2020 Author Share Posted June 14, 2020 (edited) 20 hours ago, jchd said: [...] Often enough other data structures are more efficient and maintainable. Yet there are contexts where such structures are beneficial. That was my thought too when playing around with basic bar graphs. I needed a means to bundle all relevant informations pertaining a graph, so that handling multiple graphs got possible without much hassle ("playing" as in nothing serious, getting to know autoits GUI... functions). in C, C++, Pascal or other such languages a struct (or class) would have been the prefered solution. Having used gawk (with its associative arrays, aka maps), I knew maps to be an usable alternative. I hope maps will mature over time, getting rid of the remaining flaws. In the meantime I will try M23s workaround (reassigning subarrays/maps after changes) Lorenz Edited June 14, 2020 by lorenz Link to comment Share on other sites More sharing options...
jchd Posted June 14, 2020 Share Posted June 14, 2020 Alternatively you can use scripting.dictionary object(s), potentially nested, if you need . 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...
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