mike2003 Posted February 13, 2022 Share Posted February 13, 2022 Classic array creation method Local $aArray[4] $aArray[0] = "Jasper" $aArray[1] = "Beethoven" $aArray[2] = "Pinky" $aArray[3] = "Fidget" But what if I need several arrays from a file, and I don't know how many arrays there will be? Local $aArray1[4] Local $aArray2[10] Local $aArray3[6] Local $aArray4[2] Local $aArray...[...] How can I declare arrays at runtime? Maybe an array list whose length I can change? Is there another way to store such data? Link to comment Share on other sites More sharing options...
Developers Jos Posted February 13, 2022 Developers Share Posted February 13, 2022 Did you look at the Helpfile? : https://www.autoitscript.com/autoit3/docs/intro/lang_variables.htm Quote Arrays and Maps AutoIt has 2 types of data collection variables: Arrays and Maps. Arrays are much faster for random access and can have multiple dimensions - a dimension size is fixed at the initially declared value (although it can be altered using ReDim). SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
mike2003 Posted February 13, 2022 Author Share Posted February 13, 2022 (edited) Yes > Variable subscript badly formatted.: And a lot of complaints here on the forum that this is a mistake in the help. Edited February 13, 2022 by mike2003 Link to comment Share on other sites More sharing options...
Nine Posted February 13, 2022 Share Posted February 13, 2022 Maps are only available in Beta version. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Version=Beta #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** Local $array[10] = [1,2,3,4,5,6,7,8,9,0] Local $map[] $map["SomeId"] = $array ConsoleWrite($map.SomeId[3] & @CRLF) “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
mike2003 Posted February 13, 2022 Author Share Posted February 13, 2022 I can't solve my problem in the regular version? Link to comment Share on other sites More sharing options...
Solution Nine Posted February 13, 2022 Solution Share Posted February 13, 2022 You could use the com object Scripting.Dictionnary which is very close to map : #include <Constants.au3> #include <Array.au3> $sd = ObjCreate("Scripting.Dictionary") Local $array[10] = [1,2,3,4,5,6,7,8,9,0] $sd("SomeId") = $array ConsoleWrite($sd("SomeId")[3] & @CRLF) mike2003 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
ad777 Posted February 13, 2022 Share Posted February 13, 2022 @mike2003 Local $Text = "hello";Initialize the variable $Text with data. Local $Array[] = [$Text] ;declare $Array & Automatic Get Number of $Text If IsDeclared("Array") Then MsgBox(64, "", "Declared") ;;Check if $Array is Declared iam ِAutoit programmer. best thing in life is to use your Brain to Achieve everything you want. Link to comment Share on other sites More sharing options...
mike2003 Posted February 13, 2022 Author Share Posted February 13, 2022 I'm happy with ObjCreate. But is there anything to enumerate elements? Like For - In ? Link to comment Share on other sites More sharing options...
spudw2k Posted February 13, 2022 Share Posted February 13, 2022 (edited) Yep Local $oDic = ObjCreate("Scripting.Dictionary") $oDic("USA") = "United States of America" $oDic("UK") = "United Kingdom" $oDic("CAN") = "Canada" For $obj in $oDic.keys Msgbox(0,"Key: " & $obj, " Value: " & $oDic($obj)) Next https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/dictionary-object Edited February 13, 2022 by spudw2k mike2003 1 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
mike2003 Posted February 19, 2022 Author Share Posted February 19, 2022 (edited) How can I remove a specific element? For example "UK". So that the loop now returns only two elements. Quote Removes one specified key/item pair from the Dictionary object. Edited February 19, 2022 by mike2003 Link to comment Share on other sites More sharing options...
Nine Posted February 19, 2022 Share Posted February 19, 2022 Local $oDic = ObjCreate("Scripting.Dictionary") $oDic("USA") = "United States of America" $oDic("UK") = "United Kingdom" $oDic("CAN") = "Canada" $oDic.Remove("UK") ConsoleWrite($oDic.count & @CRLF) mike2003 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy 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