pixelsearch Posted June 13 Share Posted June 13 (edited) Hello everybody I'm a total newbie to Maps in AutoIt. Instead, I used a few times the similar Scripting.Dictionary object (which is damn fast) . Maybe the advantage of Maps could be that, if one day MS removes the Scripting.Dictionary object (I doubt it but who knows...) then we'll be happy that Maps exist in recent versions of AutoIt. Anyway, I just started to learn Maps and needed to display at same time the Keys & their corresponding Values. So I scripted this simple reusable function which seems to do the job and is called by one line : _ArrayDisplay(_Map2D($mMap), "Map Keys & Values") Here is the functional example corresponding to the pic : ; AutoIt 3.3.16.1 (Map) #include <Array.au3> local $mMap[] $mMap["Beethoven"] = "Bee" $mMap["Berlioz"] = "Ber" $mMap["Chopin"] = Null ; create a key "Chopin" without assigning it a value _ArrayDisplay(_Map2D($mMap), "Map Keys & Values") Func _Map2D(Const ByRef $mMap) Local $aMapKeys = MapKeys($mMap) Local $aMap2D[Ubound($aMapKeys)][2] Local $iRow = - 1 For $vKey In $aMapKeys ; or a simple For... loop as commented out below $iRow += 1 ; 0+ $aMap2D[$iRow][0] = $vKey $aMap2D[$iRow][1] = $mMap[$vKey] Next ;~ For $i = 0 To Ubound($aMapKeys) - 1 ;~ $aMap2D[$i][0] = $aMapKeys[$i] ;~ $aMap2D[$i][1] = $mMap[$aMapKeys[$i]] ;~ Next Return $aMap2D EndFunc I just tested it on 10.000 pairs of key/values created by using the code below and the return from the function was immediate : For $i = 0 To 9999 $mMap[$i] = $i + 10 Next If you guys got some improvements for the function, please share them here, thanks. Edited June 13 by pixelsearch typo ioa747, donnyh13 and Zedna 2 1 Link to comment Share on other sites More sharing options...
ioa747 Posted June 14 Share Posted June 14 you might find this interesting 211135-map-data-fromto-file I know that I know nothing 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