TheDcoder Posted December 27, 2015 Posted December 27, 2015 Hello, I wonder if there is a better way than this!:#include <Array.au3> Local $aArray[1][3] $aArray[0][0] = 1 $aArray[0][1] = 2 $aArray[0][2] = 3 ;$aArray[0] = [1, 2, 3] _ArrayDisplay($aArray)IIRC line no. 9 should work, but its not Thanks in Advance, 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
Gianni Posted December 27, 2015 Posted December 27, 2015 in your listing you are mixing 2D and 1D arrays...?in line 2 you are using a 2d array (with just 1 row) and you can populate it like this:Local $aArray[1][3] = [[1,2,3]]if it were with 2 rows you should populate like this:Local $aArray[2][3] = [[1,2,3],[4,5,6]]while in line 9 you are declaring an 1d array, the syntax is ok, but since you are declaring a variable, you have to add the "Local" or "Global" statement. Also you should use the right number for the wanted elements [3]Local $aArray[3] = [1, 2, 3] TheDcoder 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
TheSaint Posted December 28, 2015 Posted December 28, 2015 (edited) _StringSplit if you want to start from scratch. But it also depends on the data and type.Forget the above, I had a dumb moment, where I got 3D, 2D and 1D mixed up in my head ... 2D being thought of as normal. I think some of my brain cells are still celebrating Xmas. Edited December 28, 2015 by Santa Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)
TheDcoder Posted December 28, 2015 Author Posted December 28, 2015 (edited) @Chimp Thanks! On line no. 9 I was trying to populate $aArray's Row 0 with 1, 2 & 3, Not (re)declare $aArray! @TheSaint will try Edited December 28, 2015 by TheDcoder 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
water Posted December 28, 2015 Posted December 28, 2015 Regarding line 9:You can't access a "row" of a 2D array this way. You have to access each element and fill it with data.How many elements are we talking about? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted December 28, 2015 Posted December 28, 2015 Another idea:_FileReadToArray supports CSV files so you could store your values in a file and populate the 2D array with a single line of code. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
TheDcoder Posted December 28, 2015 Author Posted December 28, 2015 How many elements are we talking about?10 elements with 3 columns each... 10 * 3 = 30 lines of code 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
TheDcoder Posted December 28, 2015 Author Posted December 28, 2015 @water Too much pain for a small task 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
water Posted December 28, 2015 Posted December 28, 2015 Global $aArray[10][3] = [[10,20,30], [11,21,31], [12,22,32], [...], [...], [...], [...], [...], [...], [19,29,39]] My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
TheDcoder Posted December 28, 2015 Author Posted December 28, 2015 @water Yeah, I know! I want to do it after declaring it... Maybe a feature request? 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
water Posted December 28, 2015 Posted December 28, 2015 Why do you want to do it after declaration? What is the advantage? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
TheDcoder Posted December 28, 2015 Author Posted December 28, 2015 @water No reason actually... would be great if it would be implemented 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
water Posted December 28, 2015 Posted December 28, 2015 Why should something be implemented that has no advantage (in our company we call it "use case")? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
TheDcoder Posted December 28, 2015 Author Posted December 28, 2015 @water Just a thought =) 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
TheSaint Posted December 28, 2015 Posted December 28, 2015 I amended my earlier post ... it is the Silly Season. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)
Moderators Melba23 Posted December 28, 2015 Moderators Posted December 28, 2015 TheDcoder,You could always use a self-coded wrapper function:#include <Array.au3> Local $aArray[1][3] Local $sInsert = "1|2|3" _ArrayReplaceRow($aArray, $sInsert, 0) _ArrayDisplay($aArray, "", Default, 8) Func _ArrayReplaceRow(ByRef $aTarget, $aSource, $iRow) _ArrayInsert($aArray, $iRow, $sInsert) _ArrayDelete($aArray, $iRow + 1) EndFuncM23 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
TheDcoder Posted December 28, 2015 Author Posted December 28, 2015 @Melba23 How did you pull this off?#include <Array.au3> Local $aArray[1][3] Local $sInsert = "1|2|3" _ArrayReplaceRow($aArray, $sInsert, 0) _ArrayDisplay($aArray, "", Default, 8) Func _ArrayReplaceRow(ByRef $aTarget, $aSource, $iRow) ; How did you manage to get $sInsert's value inside the function? Ins't it Local(ly) declared? _ArrayInsert($aArray, $iRow, $sInsert) _ArrayDelete($aArray, $iRow + 1) EndFunc 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
Moderators Melba23 Posted December 28, 2015 Moderators Posted December 28, 2015 TheDcoder,How did you pull this off?By a fluke - Local variables cannot exist outside of a function and are treated as Global even if not declared as such. What I should, of course, have posted was:#include <Array.au3> Local $aArray[1][3] Local $sInsert = "1|2|3" _Insert($aArray, $sInsert, 0) _ArrayDisplay($aArray, "", Default, 8) Func _Insert(ByRef $aTarget, $sSource, $iRow) _ArrayInsert($aTarget, $iRow, $sSource) _ArrayDelete($aTarget, $iRow + 1) EndFuncM23 TheDcoder and TheSaint 2 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
mikell Posted December 28, 2015 Posted December 28, 2015 An other -obvious- way to skin this cat...#include <Array.au3> Local $aArray[1][3] Local $sInsert = "1,2,3" _Insert($aArray, $sInsert, 0) _ArrayDisplay($aArray, "", Default, 8) Func _Insert($aTarget, $sSource, $iRow) Local $a = StringSplit($sSource, ",") For $i = 1 to $a[0] $aTarget[$iRow][$i-1] = $a[$i] Next EndFunc
Gianni Posted December 28, 2015 Posted December 28, 2015 (edited) <..snap..>removed as off topic.... Edited December 28, 2015 by Chimp Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
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