kcvinu Posted September 3, 2015 Share Posted September 3, 2015 (edited) Hi all,How to add 2 elements to a 2D array. This is my code, But not working.Local $ResArray[0][1] ; Declaring an empty array Local $Elem1 = 10 Local $Elem2 = 20 _ArrayAdd($ResArray, $Elem1, 0) ; Trying to add first column _ArrayAdd($ResArray, $Elem2, 1) ; Trying to add second column _ArrayDisplay($ResArray)This will only add the first element. Edited September 3, 2015 by kcvinu Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
Gianni Posted September 3, 2015 Share Posted September 3, 2015 if you want to add a value to column 2 you should at least declare an array wit 2 columns....tryLocal $ResArray[0][2] kcvinu 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 3, 2015 Moderators Share Posted September 3, 2015 kcvinu,You have only 1 column in your 2d array, so how do you expect the function add an element in the a non-existent column? Had you checked the @error return from the second call to _ArrayAdd (4 - $iStart outside array bounds) you would have discovered this in less time that it took to post.#include <Array.au3> Local $ResArray[0][2] ; 2 column array Local $Elem1 = 10 Local $Elem2 = 20 _ArrayAdd($ResArray, $Elem1, 0) _ArrayAdd($ResArray, $Elem2, 1) _ArrayDisplay($ResArray)M23 kcvinu 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 Link to comment Share on other sites More sharing options...
kcvinu Posted September 3, 2015 Author Share Posted September 3, 2015 (edited) Thanks But this was eating my head. Sorry to say. This not what i want. I want 10 & 20 in one row. Edited September 3, 2015 by kcvinu Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
kcvinu Posted September 3, 2015 Author Share Posted September 3, 2015 (edited) At last this workedLocal $ResArray[0][2] Local $Elem1 = 10 Local $Elem2 = 20 Local $temp = $Elem1 & "," & $Elem2 _ArrayAdd($ResArray, $temp, 0,",") _ArrayDisplay($ResArray)Is there any other way to do this Edited September 3, 2015 by kcvinu Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
mikell Posted September 3, 2015 Share Posted September 3, 2015 _ArrayAdd($ResArray, $Elem1 & "," & $Elem2, 0, ",") kcvinu 1 Link to comment Share on other sites More sharing options...
kcvinu Posted September 3, 2015 Author Share Posted September 3, 2015 @mikell , Short form of my code. You will benefit one line and an extra variable. Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
Gianni Posted September 3, 2015 Share Posted September 3, 2015 ... even shorter #include <Array.au3> Local $ResArray[1][2] = [[10, 20]] _ArrayDisplay($ResArray) kcvinu 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 3, 2015 Moderators Share Posted September 3, 2015 kcvinu,Or just use the default delimiter:#include <Array.au3> Local $ResArray[0][2] ; 2 column array Local $Elem1 = 10 Local $Elem2 = 20 _ArrayAdd($ResArray, $Elem1 & "|" & $Elem2) _ArrayDisplay($ResArray)M23 kcvinu 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 Link to comment Share on other sites More sharing options...
kcvinu Posted September 3, 2015 Author Share Posted September 3, 2015 @Melba23 Thanks.@Chimp , Actually, that is not what i wanted. I need to populate a 2D array with this ArrayAdd function. Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
mikell Posted September 3, 2015 Share Posted September 3, 2015 kcvinu,I posted this - as a joke - because I can't imagine how to use _ArrayAdd in a shorter way, except as said Melba by using the default delimiter kcvinu 1 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