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.

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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

 

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

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

@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

 

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

  • 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

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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