knuxfighter Posted February 2, 2017 Posted February 2, 2017 (edited) Hello. I'm just learning Python at school but I like to use AutoIt also, I can't get past one thing though. Lets say I have some information about chars and their ASCII value but I don't have it sorted. The idea is that information about every char is stored in its own subarray. How can I extract the value of lets say char 2 which should return something like this? ["a", 97] As in python you just write array[1] and it returns the second subarray, but how do you do this in AutoIt? Thanks! $array = [["b", 98], ["a", 97], ["c", 99]] I already read some topics about this but the solutions seemed very complicated but there should be an easy solution for this as this is a basic operation (I suppose) Edited February 2, 2017 by knuxfighter
Moderators Melba23 Posted February 2, 2017 Moderators Posted February 2, 2017 (edited) knuxfighter, It is not that difficult: #include <Array.au3> Global $aArray2D[][] = [["b", 98], ["a", 97], ["c", 99]] ; Extract the data for element [1] $aExtract = _ArrayExtract($aArray2D, 1, 1) _ArrayDisplay($aExtract, "", Default, 8) Please ask if you have any questions. M23 Edited February 2, 2017 by Melba23 27k Skysnake 1 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
knuxfighter Posted February 2, 2017 Author Posted February 2, 2017 4 minutes ago, Melba23 said: knuxfighter, It is not that difficult: #include <Array.au3> Global $aArray2D[][] = [["b", 98], ["a", 97], ["c", 99]] ; Extract the data for element [1] $aExtract = _ArrayExtract($aArray2D, 1, 1) _ArrayDisplay($aExtract, "", Default, 8) Please ask if you have any questions. M23 Thank you. I have one more question. How do I add ["d", 100] to the end of the array? Probably I have to resize the array to size+1 as none of the following seem to work: $aArray2D[3][0] = "d" $aArray2D[3][1] = 100 $aArray2D[3] = ["d", 100] _ArrayAdd($aArray2D, ["d", 100]) _ArrayAdd($aArray2D[3][0], "d") _ArrayAdd($aArray2D[3][1], 100) Or is there any simpler solution? Thank you again
Moderators Melba23 Posted February 2, 2017 Moderators Posted February 2, 2017 knuxfighter, #include <Array.au3> Global $aArray2D[][] = [["b", 98], ["a", 97], ["c", 99]] _ArrayAdd($aArray2D, "d|100") _ArrayDisplay($aArray2D, "", Default, 8) Look in the remarks section of the help file page for _ArrayAdd to see the correct syntax for adding elements to arrays. M23 knuxfighter 1 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
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