Jump to content

Recommended Posts

Posted

Wow this looks cool, I am sure it will come in handy.  I just sort of got comfortable with Arrays not too long ago, I assume that Maps are going to be sort of like RegEx.

"The best practice is to not use them unless you need them" and still stick to Arrays for most tasks.

I would love to see some real life examples however of where a map can more easily do what an array could not so that I can sort of wrap my head around when this would be best used or make a task easier. 

Posted

use a For..In Loop, instead of a For...To Loop.     Unless thats bad form, imho it looks cleaner.

  Reveal hidden contents

Posted (edited)

@JohnOne :P People in the shopping mall wanted some sandal wood

@boththose How can I get the key to the element if I use For...In?

Edited by TheDcoder
forgot to reply boththose

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Posted
#include <MsgBoxConstants.au3>

; Lets create our map first
Local $mMap[]

; Lets add some information to the map, feel free to modify & add new elements
$mMap["Name"] = "Damon Harris"
$mMap["Alias"] = "TheDcoder"
$mMap["Gender"] = "Male"
$mMap["Age"] = 14
$mMap["Location"] = "India"

$aMapKeys = MapKeys($mMap) ; MapKeys function returns all the keys in the format of an array
Local $sProfile = "Profile of " & $mMap[$aMapKeys[0]] & ':' & @CRLF ; We will use this string later

For $Key In $aMapKeys
    msgbox(0, '' , $Key & " = " & $mMap[$Key])
next

 

  Reveal hidden contents

Posted (edited)

You can also keep your Funcs in your map with your data

; Lets create our map first
Local $mMap[]

; Lets add some information to the map, feel free to modify & add new elements
$mMap["Name"] = "Damon Harris"
$mMap["Alias"] = "TheDcoder"
$mMap["Gender"] = "Male"
$mMap["Age"] = 14
$mMap["Location"] = "India"
$mMap["Keys"] = MapKeys($mMap)


For $Key In $mMap["Keys"]
    If $Key <> "Keys" Then msgbox(0, '' , $Key & " = " & $mMap[$Key])
next

 

Edited by boththose

  Reveal hidden contents

Posted

I really don't like documenting alpha (not beta) functionality in the open Forum, because it's suggesting that this will at some point be included in a future release of AutoIt, unless @TheDcoder has been told something I don't know about?!

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

@guinness I think I will update the introduction to be more specific on the current stage of development of maps :)

  On 10/22/2015 at 6:17 PM, guinness said:

@TheDcoder has been told something I don't know about?!

Ummm... Maybe.... Maybe Not :P

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Posted

i would want to explore maps in maps to achieve the OP.  start at the smallest unit throwing them into larger and larger containers..

Local $mMapGlo[]
Local $mMapLocAus[]
Local $mMapLocDal[]
Local $mMapPersonNorth[]
Local $mMapPersonSouth[]
Local $mMapPersonDallas[]


$mMapPersonNorth["Jeff"] = "Jeff in N. Austin"
$mMapPersonSouth["Jack"] = "Jack in S. Austin"
$mMapPersonDallas["John"] = "John in Dallas"

$mMapLocAus["NorthAus"] = $mMapPersonNorth
$mMapLocAus["SouthAus"] = $mMapPersonSouth
$mMapLocDal["Dallas"] = $mMapPersonDallas

$mMapGlo["CentralTx"] = $mMapLocAus
$mMapGlo["NorthTx"] = $mMapLocDal


For $loc in $mMapGlo
    For $key in mapkeys($loc)
        For $item in $loc[$key]
            msgbox(0, '' , $key & @LF & $item)
        Next
    Next
next

 

  Reveal hidden contents

  • 2 weeks later...
Posted (edited)

maps are similar to scripting.dictionary which is similar to an ini which i guess is similar to a 2D array with equal signs?

Edited by boththose

  Reveal hidden contents

Posted

@MartinMarris  I thinks its a yes... I am not familiar with the concept of dynamic arrays but a quick google search explained me about them, though I didn't use them, I can say that a Map is similar (not same) to dynamic arrays, Resizing a map (i.e adding or removing elements from it) is faster compared to arrays.

 

Sorry for late reply, I was busy, TD :)

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

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
×
×
  • Create New...