JohnOne Posted August 20, 2014 Share Posted August 20, 2014 beta 3.3.13.17 is the first beta I've installed since 3.3.12.0 was released. How do Maps work? Seems from the help file that it's a scripting dictionary object with some methods coded into it already. I'm probably wrong though. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
jchd Posted August 20, 2014 Share Posted August 20, 2014 Kinda. Map keys can be integers or case-sensitive strings and values can be any AutoIt datatype. Maps are not objects but internal datatype and retain insertion order. 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...
Ascend4nt Posted August 20, 2014 Share Posted August 20, 2014 Are there beta docs up on this site that can be linked to? That could be a start. Not everyone is going to touch the betas, but some interest can be generated by showing what the current documentation says without copying-and-pasting it here (and then keeping up with updates). By the way, the current implementation looks like other language implementations of maps, hashtables, and associative arrays (Javascript objects, PHP arrays, C++ sets/maps, C# Dictionary/Hash tables, D associative arrays) etc. My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 20, 2014 Moderators Share Posted August 20, 2014 Ascend4nt,As I explained before, everything that is known about maps is in the Beta Help file. There are a few native functions under <Map management> and some explanation on the <Language Reference - Variables> page. We are not holding back on anything - there are no secret functions or functionality that will suddenly appear. There is a very early Alpha Map UDF, but as we have no idea what people might want to do with the new datatype there seems little point in developing it past that stage for the moment. The content at present is:; _MapConcatenate ; _MapDisplay ; _MapFindAll ; _MapMaxKey ; _MapMaxValue ; _MapMinKey ; _MapMinValue ; _MapRenameKey ; _MapSearch ; _MapToArray ; _MapToClip ; _MapToStringand if it looks a lot like the Array library it should! Maps were announced some 5 weeks ago in the Beta 3.3.13.3 thread and subsequent Betas have made reference to any changes made to syntax and function names. But the usual complete indifference of most people to testing new additions seems to have occurred - they seem to like waiting until a full release before announcing that they have found problems. >So there you have the current state of play - enjoy. 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...
Ascend4nt Posted August 20, 2014 Share Posted August 20, 2014 As I explained before, everything that is known about maps is in the Beta Help file. As I said: Not everyone is going to touch the betas, but some interest can be generated by showing what the current documentation says If you don't at least expose that information on the site (beta documentation), people may just well skip the betas not knowing what new features are brought to the table or how they can be used. Again, to give features exposure you need to generate interest in them. Noone's done a good job in that respect. JohnOne can at least be commended for posting this thread, which is a step forward. However, thanks for the other information. My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
Administrators Jon Posted August 20, 2014 Administrators Share Posted August 20, 2014 By the way, the current implementation looks like other language implementations of maps, hashtables, and associative arrays (Javascript objects, PHP arrays, C++ sets/maps, C# Dictionary/Hash tables, D associative arrays) etc. Pretty much. I liked the way you could have integer and strings keys and also liked the idea of it staying in order of insertion when iterated. For background, the way I implemented it internally was by creating a generic AObject class that allows something to have properties and methods and then derived the Map class from this. Then the COM parser code is used to process it and can have a simple check in it of "is it a COM object or a generic AObject" then uses polymorphism to just "check for method", "call method" etc. Makes it easy to add object types in the future or add the lua-like table that trancexx was looking at. This is where the .Add() and .Keys() methods came in along with the .properties. But we had some discussions amongst ourselves and a lot of languages look really ugly when they try and mix procedural syntax and object-like syntax. I rewrote some function code to allow built-in functions to pass by reference so that functions like MapAdd() can now exist properly. So that's the main decision to be made. Pure object methods and properties, or remove the methods and properties and just use the Map...() functions and array-like access like $map["key"]. That's why both are still there at the mo - just can't decide. Even though it's implemented as an object internally, we don't have to expose that with .Methods if we don't like it. I implemented it as a value-type as well (like Array) but there were some discussions about having it behave like a reference type instead so that you could reference maps inside maps rather than just copies of maps. But I thought that it makes sense that arrays and maps should behave the same in that respect and it would be more useful to create a way in the language of creating a reference. I've not been able to get it to work though - the parser design just isn't up to it. At the mo I'm planning to do a stable release soon because there's been some big bugs fixed that I want out there, but that will almost certainly have maps disabled and then roll them into the next beta. Ascend4nt 1 Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
Ascend4nt Posted August 21, 2014 Share Posted August 21, 2014 (edited) Jon, thanks for taking the time out to describe what the status of Map is, as well as how it works internally. I suppose the safe bet for people experimenting would be to use array-like access $mMap["property"] as that would be easier to use a RegEx on to fix it up. From some simple tests, it appears that array-access function call syntax works, while property access doesn't. Here's just a random experiment I've created: expandcollapse popupFunc MyFunc() ConsoleWrite("Called MyFunc"&@LF) EndFunc Func ShowString(Const ByRef $mMap) If MapExists($mMap, "myString") Then ConsoleWrite("Map string = " & $mMap.myString & @LF) EndFunc Func TestMaps() Local $aArr[1], $mMap[], $mMap2[] ; Indirect function call using array $aArr[0] = MyFunc $aArr[0]() ; Indirect function call using Map & array-style access $mMap["func"] = MyFunc $mMap["func"]() ; Indirect function call using Map & member/property access $mMap2.func = MyFunc ;$mMap2.func() ; Fails currently ; Value assign & access: $mMap["val"] = 1 ConsoleWrite("Map1 value = " & $mMap.val & @LF) ; member/property version $mMap2.val = 4 ConsoleWrite("Map2 value = " & $mMap2.val & @LF) ; More values $mMap["myString"] = "aMap string" $mMap2.myString = "aMap2 string" ; Passing maps as parameters ShowString($mMap) ShowString($mMap2) EndFunc TestMaps() There's obviously great potential here for creating simple interfaces and pseudo-objects, but for now I'm going to start light.. *edit: see >this post for an extended example, plus Beta docs links Edited August 25, 2014 by Ascend4nt My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
Mat Posted August 21, 2014 Share Posted August 21, 2014 Calling a member function with dot access works, but you have to surround it in parenthesis: ($mMap2.func)() AutoIt Project Listing Link to comment Share on other sites More sharing options...
jpm Posted August 21, 2014 Share Posted August 21, 2014 Calling a member function with dot access works, but you have to surround it in parenthesis: ($mMap2.func)() I don't think this syntax will be supported by Au3Check but who knows ... Link to comment Share on other sites More sharing options...
JohnOne Posted August 21, 2014 Author Share Posted August 21, 2014 I don't think this syntax will be supported by Au3Check but who knows ... Hey jpm are there any ignore options in au3check for certain parts of code such as the one above, instead of disabling it? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
jpm Posted August 21, 2014 Share Posted August 21, 2014 If you know how the Au3Check is written, you could understand my remarks. We don't intend to rewrite Au3Check from scratch Sorry Link to comment Share on other sites More sharing options...
JohnOne Posted August 21, 2014 Author Share Posted August 21, 2014 I don't know how it's written, but I'll have to take that as a no. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
jpm Posted August 21, 2014 Share Posted August 21, 2014 I don't know how it's written, but I'll have to take that as a no. Unless Some Dev as Jos find soultion ... Link to comment Share on other sites More sharing options...
JohnOne Posted August 21, 2014 Author Share Posted August 21, 2014 You mean if the encompassing braces were not required, au3check could handle that? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
jpm Posted August 21, 2014 Share Posted August 21, 2014 Will see what Jos can say about Link to comment Share on other sites More sharing options...
Ascend4nt Posted August 25, 2014 Share Posted August 25, 2014 Calling a member function with dot access works, but you have to surround it in parenthesis: ($mMap2.func)() Thanks for that. That's pretty ugly syntax, but I get that the parser has issues with it otherwise. Anyway, I've updated my example after testing it on various embedded datatypes. I was actually surprised to find out that DLLStructs are passed by reference (in stable and beta), rather than a copy being made.. interesting. Also, the embedded-array access issue is a bit annoying, but that problem has been present with arrays-within-arrays as well. Also, since Jon was cool enough to update the Beta docs, here's a link for anyone that hasn't played with the Beta's yet: Overall: https://www.autoitscript.com/autoit3/files/beta/autoit/docs/ (currently, the Variables section has an overview of Maps, and Functions lists the Mapxx functions) Also, the Map Management section: https://www.autoitscript.com/autoit3/files/beta/autoit/docs/functions/Map%20Management.htm expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Version=Beta #AutoIt3Wrapper_Outfile=MapTests.exe #AutoIt3Wrapper_Change2CUI=y #AutoIt3Wrapper_Run_AU3Check=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; ------------------------------------------------------------------------------------------- ; Map Tests ; ; Requires AutoIt beta (v3.3.13.18 tested) ; ------------------------------------------------------------------------------------------- ; NOTES: ; ----- ; - Embedding other complex datatypes: ; Anything inserted in Arrays and Maps are COPIES of the objects, ; EXCEPT for DLLStruct's, which are reference types (at least in current AutoIt versions) ; So, modifying embedded Arrays and Maps will NOT alter the originals ; ; - Calling functions: ; Must be done using Map["func"]() or (Map.func)() ; Functions in Arrays work with Arr[i]() ; ; - Arrays within Maps/Arrays: ; Write access: ; No manner of subscript access works, and parentheses around an expression causes a copy ; to be made, which discards the value at the end of the statement ; A function taking an Array ByRef can be used to workaround the problem, however ; ; Read access: ; dot-member access works: ; Map.arr[0] ; However for both Maps and arrays, using subscript operators requires parentheses: ; (Map["arr"])(0) ; (Arr[0])[0] ; ; - Maps inside maps: ; Read/Write access: ; Map["map"]["val"] ; Map.map.val ; ; - Maps within Arrays: ; Write access: ; Arr[3].data ; Read access: ; Arr[3].data ; (Arr[3])["data"] ; ; - DLLStructs' produce references to the original structure (in current AutoIt versions) ; Read/Write access depends on Array or Map container: ; Arr[i].stVal ; Map["struct"].stVal ; Map.struct.stVal ; ; ------------------------------------------------------------------------------------------- Func MyFunc() ConsoleWrite("Called MyFunc"&@LF) EndFunc Func ShowString(Const ByRef $mMap) If MapExists($mMap, "myString") Then ConsoleWrite("Map string = " & $mMap.myString & @LF) EndFunc Func ModifyArrayValue(ByRef $aArr, Const $i, Const ByRef $vData) If IsArray($aArr) Then $aArr[$i] = $vData EndFunc Func TestMaps() Local $aArr[4], $mMap[], $mMap2[] ;Dim $mMap2[] ; Also works for declaring/redeclaring variable as Map ;; -= Function call Tests -= ; Indirect function call using array $aArr[0] = MyFunc $aArr[0]() ; Indirect function call using Map & array-style access $mMap["func"] = MyFunc $mMap["func"]() ; Indirect function call using Map & member/property access $mMap2.func = MyFunc ; Awkward syntax which works (Au3Check fails to handle this, however) ($mMap2.func)() ;$mMap2.func() ; Preferred syntax (which doesn't work) ;; -= Value assignment Tests =- ; array-style assign & access: $mMap["val"] = 1 ConsoleWrite("Map1 value = " & $mMap["val"] & @LF) ; member/property version $mMap2.val = 4 ConsoleWrite("Map2 value = " & $mMap2.val & @LF) ; More values $mMap["myString"] = "aMap string" $mMap2.myString = "aMap2 string" ; Passing maps as parameters ShowString($mMap) ShowString($mMap2) ;; -= Embedded Array tests =- Local $aEmbedArr[2] = [1, 2] ; Makes *COPY* of array inside Map $mMap.arr = $aEmbedArr ; Modifying embedded array: ; Member/property access doesn't work: ;$mMap.arr[0] = 20 ; Parentheses around a value forces a copy to be made [per Jon], not a reference: ;~ ($mMap.arr)[0] = 20 ; copy is made, and discarded ; array-style access doesn't work either: ;$mMap["arr"][0] = 20 ; Indirect workaround (pass array as reference): ModifyArrayValue($mMap.arr, 0, 20) ConsoleWrite("Map:Embedded-Array elements:"&@LF) ; array-style access For $i = 0 To UBound($mMap["arr"]) - 1 ; Note Awkward syntax for getting internal array element: ; ($mMap["arr"])($i) ConsoleWrite("#" & $i & " = " & ($mMap["arr"])[$i] & @LF) Next ; Member/property access: ConsoleWrite("[alternate member/property access]:"&@LF) For $i = 0 To UBound($mMap.arr) - 1 ConsoleWrite("#" & $i & " = " & $mMap.arr[$i] & @LF) Next ; .. 'EmbeddedArray' value remains the same as its initial assignment: ConsoleWrite("..aEmbedArr[0] = " & $aEmbedArr[0] & @LF) ;; - Embedded array in array (no Map) - ; Makes *COPY* of EmbedArray inside Array $aArr[1] = $aEmbedArr ; Doesn't work: ;$aArr[1]0] = 40 ; Parentheses around a value forces a copy to be made [per Jon], not a reference: ;~ ($aArr[1])[0] = 40 ; copy is made, and discarded ; Indirect workaround (pass array as reference): ModifyArrayValue($aArr[1], 0, 40) ConsoleWrite("Array:Embedded-Array elements:"&@LF) ; array-style access For $i = 0 To UBound($aArr[1]) - 1 ; Note Awkward syntax for getting internal array element: ; ($aArr[1])[$i] ConsoleWrite("#" & $i & " = " & ($aArr[1])[$i] & @LF) Next ; .. 'EmbeddedArray' value remains the same as its initial assignment: ConsoleWrite("..aEmbedArr[0] = " & $aEmbedArr[0] & @LF) ;; -= Structures =- Local $tStruct = DllStructCreate("int MyInt;") ; Structure normal access: DllStructSetData($tStruct, "MyInt", 10) ; Structure property-access: $tStruct.myInt = 20 ; Assign structure to Map (actually creates a reference rather than a copy) $mMap.struct = $tStruct ; Modify structure data (both ways work) $mMap.struct.myInt = 40 $mMap["struct"].myInt = 60 ConsoleWrite("mMap.struct.myInt = " & $mMap.struct.myInt & @LF) ; Struct Inside array (creates reference to original struct) $aArr[3] = $tStruct $aArr[3].myInt = 80 ConsoleWrite("aArr[3].myInt = " & $aArr[3].myInt & @LF) ; Original Structure is modified by all operations above (even embedded in Maps or Arrays) ConsoleWrite("tStruct.myInt = " & $tStruct.myInt & @LF) ConsoleWrite("DLLStructGetData($tStruct, 'myInt') = " & DllStructGetData($tStruct, "myInt") &@LF) ;; -= Maps within Maps =- Local $mEmbedMap[] $mEmbedMap.innerVal = 4 ; This causes a *COPY* of $mEmbedMap to be added to $mMap: $mMap.embeddedMap = $mEmbedMap ; Modifying the embedded map doesn't affect the external one $mMap.embeddedMap.innerVal = 10 ConsoleWrite("Map.embeddedMap.innerVal = " & $mMap.embeddedMap.innerVal & @LF) ; Alternate ways of writing the above line: ; (Note how 2 subscripts can be used here, as opposed to embedded arrays): ConsoleWrite("Map[embeddedMap][innerVal] = " & $mMap["embeddedMap"]["innerVal"] & @LF) ConsoleWrite("Map[embeddedMap].innerVal = " & $mMap["embeddedMap"].innerVal & @LF) ; .. 'EmbedMap' value remains the same as its initial assignment: ConsoleWrite("..EmbedMap.innerVal = " & $mEmbedMap.innerVal & @LF) ;; -= Maps within Arrays =- ; Creates a *COPY* of Map inside array $aArr[3] = $mEmbedMap $aArr[3].innerVal = 20 ; Parentheses around a value forces a copy to be made [per Jon], not a reference: ;~ ($aArr[3])["innerVal"] = 40 ; copy is made, and discarded ConsoleWrite("Arr[embeddedMap].innerVal = " & $aArr[3].innerVal &@LF) ; Note Awkward syntax for getting internal array element: ; ($aArr[3])["innerVal"] ConsoleWrite("(Arr[embeddedMap])[innerVal] = " & ($aArr[3])["innerVal"] &@LF) ; .. 'EmbedMap' value remains the same as its initial assignment: ConsoleWrite("..EmbedMap.innerVal = " & $mEmbedMap.innerVal & @LF) EndFunc TestMaps() My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
JohnOne Posted August 25, 2014 Author Share Posted August 25, 2014 What I'm struggling to understand about array access within a map is that if the value can be retrieved I'd have thought it could be set. With an array in an array, you cannot even get a value of an element. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
guinness Posted August 26, 2014 Share Posted August 26, 2014 Here... Local $aInternal = [99, "Problems"] Local $aArray = [$aInternal] ConsoleWrite(($aArray[0])[0] & " " & ($aArray[0])[1] & @CRLF) Xandy 1 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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Ascend4nt Posted September 20, 2014 Share Posted September 20, 2014 So, for the Map types to become a really well integrated part of the language, there needs to be some support for string literal assignments. Without this kind of support, its very tedious to use Maps in many situations. When I talk literals, I mean something like this: $mMap [] = { "val" : 1, "valB" : $nVal, "name" : "Bob Smith", "array" : $myArray} There's other ways to do the above, depending on the language, but I think that is one of the easiest ways to format it. Anyway, for anyone looking to add *very* simplistic Map-literal assignment/addition to a Map, here's an example of how it could be done for the simplest of types (alphanumeric kinds of assignments): expandcollapse popup; ================================================================================================= ; Func _MapCreateFromStringLiteral($sMapLits) ; ; Given a string literal, creates and adds key/values to a new map which is returned. ; Note this is VERY simplistic and is really more for alphanumeric types of assignments. ; ; String literal for Maps is in the form of Javascript & D, except with quotes in place of brackets ; Example: ; "[valA : mapVal, valB : 123, 3 : 4]" is the equivalent of: ; Map["valA"] = "mapVal" ; Map["valB"] = "123" ; Map["3"] = "4" ; ; Note that currently there is no numeric conversion ("123" doesn't get converted to 123), ; however comparisons like ("123" = 123" work in AutoIt ; ; Returns: ; Success: new Map ; Failure: "" with @error set ; ; Author: Ascend4nt ; ================================================================================================= Func _MapCreateFromStringLiteral($sMapLits) Local $mMap [] If Not _MapAddFromStringLiteral($mMap, $sMapLits) Then Return SetError(@error, @extended, "") Return $mMap EndFunc ; ================================================================================================= ; Func _MapAddFromStringLiteral(ByRef $mMap, $sMapLits) ; ; Given a string literal, creates and adds key/values to the given Map parameter. ; Note this is VERY simplistic and is really more for alphanumeric types of assignments. ; ; String literal for Maps is in the form of Javascript & D, except with quotes in place of brackets ; Example: ; "{valA : mapVal, valB : 123, 3 : 4}" is the equivalent of: ; Map["valA"] = "mapVal" ; Map["valB"] = "123" ; Map["3"] = "4" ; ; Note that currently there is no numeric conversion ("123" doesn't get converted to 123), ; however comparisons like ("123" = 123") work in AutoIt ; ; Returns True on success, False on failure with @error set ; ; Author: Ascend4nt ; ================================================================================================= Func _MapAddFromStringLiteral(ByRef $mMap, $sMapLits) If Not IsString($sMapLits) Or $sMapLits = "" Or Not IsMap($mMap) Then Return SetError(1, 0, False) ; Pull out "key:val" pairs. Optional whitespace surrounds each element (comma typically separates the pairs) Local $aMapVals = StringRegExp($sMapLits, "(\w+)\s*:\s*(\w+)", 3) If @error Then Return SetError(1, 0, False) For $i = 0 To (UBound($aMapVals) - 1) Step 2 ;ConsoleWrite("Next assignment: Key '" & $aMapVals[$i] & "' = " & $aMapVals[$i + 1] & @CRLF) $mMap[$aMapVals[$i]] = $aMapVals[$i + 1] Next Return True EndFunc ;; -= Map from Literals =- Local $mMapFromLits = _MapCreateFromStringLiteral("{byte:1, short:2, int:4, int64:8, float:4, double:8}") _MapAddFromStringLiteral($mMapFromLits, "{ char : 1 , wchar : 2 }") ConsoleWrite("# of Keys in $mMapFromLits = " & UBound($mMapFromLits) & ":" & @CRLF) For $kKey In MapKeys($mMapFromLits) ConsoleWrite("Map['" & $kKey & "'] = " & $mMapFromLits[$kKey] & @CRLF) Next My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
TheDcoder Posted October 20, 2015 Share Posted October 20, 2015 (edited) Maps accepts any datatype as an key? Local $mMap[] $mMap["String"] = "String Map" $mMap[0] = "Integer Map" $mMap[0.1] = "Float Map" $mMap[True] = "Bool Map" MsgBox(0, 0, $mMap["String"] & @CRLF & $mMap[0] & @CRLF & $mMap[0.1] & @CRLF & $mMap[True]) Edited October 20, 2015 by TheDcoder Forgot to declare $mMap :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 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