MirnesC2 Posted May 20, 2013 Share Posted May 20, 2013 (edited) My goal is to have an array that contains other arrays... a 2D array. Array $data[4][3] 0 - Array 0 - Id 1 - Name 2 - Price 1 - Array 0 - Id 1 - Name 2 - Price 2 - Array 0 - Id 1 - Name 2 - Price 3 - Array 0 - Id 1 - Name 2 - Price I want to structure my array like this so I can pull data from it easily like this... If I want to know the price of the 2nd item in the array I would call for it using $data[1][2]. This is how I tried to do this but it isn't working. Each different attempt gives a different error message. I don't see what I am doing wrong, maybe someone with more experiance than me can pick up on it? Thanks and Please! #include <Array.au3> Local $data[10] For $i = 0 To 10-1 Step +1 $data[$i] = ["1987", "Toothbursh", "$4.00"] Next _ArrayDisplay($arr) Error Produced (from console window in SciTe) >"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\USER\Desktop\asdas.au3" C:\Users\Mirnes\Desktop\asdas.au3 (7) : ==> Error in expression.: $data[$i] = ["1987", "Toothbursh", "$4.00"] $data[$i] = ^ ERROR >Exit code: 1 Time: 0.230 I then figured that my error was not defining the 2nd dimension in the array so I changed $data[10] to $data[10][3] but it just produced a new error message. #include <Array.au3> Local $data[10][3] For $i = 0 To 10-1 Step +1 $data[$i] = ["1987", "Toothbursh", "$4.00"] Next _ArrayDisplay($arr) Error Produced (from console window in SciTe) >"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\USER\Desktop\asdas.au3" C:\Users\Mirnes\Desktop\asdas.au3 (5) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $data[$i] = ["1987", "Toothbursh", "$4.00"] ^ ERROR >Exit code: 1 Time: 0.222 Edited May 20, 2013 by MirnesC2 Link to comment Share on other sites More sharing options...
guinness Posted May 20, 2013 Share Posted May 20, 2013 Does $pId have the same number of items as $rHeader? Also remove that Step -1 please. 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...
MirnesC2 Posted May 20, 2013 Author Share Posted May 20, 2013 Does $pId have the same number of items as $rHeader? Also remove that Step -1 please. All the arrays have the same number of items. What Step -1? Step +1? How will the For-loop increase? Link to comment Share on other sites More sharing options...
Developers Jos Posted May 20, 2013 Developers Share Posted May 20, 2013 So you want to fill a one dimensional Array with values in 2 Dimensions ? 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...
MirnesC2 Posted May 20, 2013 Author Share Posted May 20, 2013 (edited) So you want to fill a one dimensional Array with values in 2 Dimensions ? I guess your trying to tell me I'm doing it wrong? Array $array 00 00 - ID 01 - Name 02 - Price 03 - Location 04 - Date 01 00 - ID 01 - Name 02 - Price 03 - Location 04 - Date 02 00 - ID 01 - Name 02 - Price 03 - Location 04 - Date I want have an array like $array[10][5]. So if I want to know the price of the 5th item in the array I would call for it using $array[4][2]. That is my goal but it's not really working out the way I wanted it to Edited May 20, 2013 by MirnesC2 Link to comment Share on other sites More sharing options...
guinness Posted May 20, 2013 Share Posted May 20, 2013 Leave it without the Step value as the default is +1. What about this? $array[$i] = [$pId[$i] & @CRLF & $pName[$i] & @CRLF & $pPrice[$i] & @CRLF & $pLocat[$i] & @CRLF & $pDate[$i]] Also where is the 2D array please? 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...
MirnesC2 Posted May 20, 2013 Author Share Posted May 20, 2013 (edited) Leave it without the Step value as the default is +1. What about this? $array[$i] = [$pId[$i] & @CRLF & $pName[$i] & @CRLF & $pPrice[$i] & @CRLF & $pLocat[$i] & @CRLF & $pDate[$i]] Also where is the 2D array please? If it's default is +1 and me adding +1 doesn't effect it at all then why change it? It helps me and doesn't harm anything. Everyone has their own style. You seem to be working backwards from the question and the sarcasm really isn't contributing to anything either. I understand that I need to declare a second dimension Local $array[$num][5] But doing so doesn't solve my problem it just causes another sub-script error. Adding & only combines the data into a single string. And the @CRLF abstruct my data. Each loop in the for-loop should be adding an array to the array $array... but it isn't working. Hence a 2D array... Edited May 20, 2013 by MirnesC2 Link to comment Share on other sites More sharing options...
guinness Posted May 20, 2013 Share Posted May 20, 2013 (edited) You seem to be working backwards from the question and the sarcasm really isn't contributing to anything. Pardon? I wasn't being sarcastic. As you will note I said Step -1, because on my screen at a quick glance it looked like -1 and not +1, the orange colour can be a little difficult to see at times. But seems as though you don't need help anymore, as you're on some kind of track. Good luck. Edited May 20, 2013 by guinness 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...
Developers Jos Posted May 20, 2013 Developers Share Posted May 20, 2013 (edited) You're funny MirnesC2,.... You post a half ass questions about some error and don't even bother specifying what you really want nor post a script that might help to understand and you expect a good answer without any questions? As you are around long enough I would recommend re-reading that linked Wiki page because you are not using the correct method for defining and populating the array, Jos Edited May 20, 2013 by Jos 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...
MirnesC2 Posted May 20, 2013 Author Share Posted May 20, 2013 Pardon? I wasn't being sarcastic.The way you say please and the questions you seem to be asking can be viewed as slightly sarcastic and loathsome. But I can see now that English might not be your first language so it wasn't intential.As you will note I said Step -1, because on my screen at a quick glance it looked like -1 and not +1, the orange colour can be a little difficult to see at times.I can completely understand you for that and would not blame you for it. But you tried to play it off by making it look like I was doing something wrong instead of saying that.You're funny MirnesC2,.... You post a half ass questions about some error and don't even bother specifying what you really want nor post a script that might help to understand and you expect a good answer without any questions?As you are around long enough I would recommend re-reading that linked Wiki page because you are not using the correct method for defining and populating the array,I'm sorry if I offended somehow. Having questions for me is understandable... and I answered them. I thought that the question was understandable enough. I will try to edit it right now, make it more understandable. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 20, 2013 Moderators Share Posted May 20, 2013 Wow, disrespecting a long-standing member of this forum, known for his great support, in the same topic you're asking for help in - not the most intelligent thing I've ever seen. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
guinness Posted May 20, 2013 Share Posted May 20, 2013 English might not be your first language so it wasn't intential. Well it is. 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...
kylomas Posted May 20, 2013 Share Posted May 20, 2013 Well it is. Comically ironic, albeit hardly "intentional"... MirnesC2 - Your answers are in the previous posts, please don't read into the text things that are not there. Yo want to populate a 2D array using the syntax "array[row][column]". Do not exceed the boundaries of any subscripts (your last error). There are thousands of examples of 2D arrays on the forum. Put something together, identify exactly what the problems are and you will get all the help you need. kylomas MirnesC2 1 Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
jdelaney Posted May 20, 2013 Share Posted May 20, 2013 couple examples #include <Array.au3> $iTotalAmountOfItems = 10 Global Enum $iArray_ID, $iArray_Name, $iArray_Price, $iArray_UBound Global $aArray[$iTotalAmountOfItems][$iArray_UBound] For $i = 0 To UBound($aArray)-1 For $j = 0 To UBound($aArray,2)-1 Switch $j Case $iArray_ID $aArray[$i][$j] = "ID:" & $i & "," & $j Case $iArray_Name $aArray[$i][$j] = "Name:" & $i & "," & $j Case $iArray_Price $aArray[$i][$j] = "Price:" & $i & "," & $j EndSwitch Next Next _ArrayDisplay($aArray) Global $aArray2[$iTotalAmountOfItems][$iArray_UBound] For $i = 0 To UBound($aArray)-1 $aArray2[$i][$iArray_ID] = "ID:" & $i $aArray2[$i][$iArray_Name] = "Name:" & $i $aArray2[$i][$iArray_Price] = "Price:" & $i Next _ArrayDisplay($aArray2) MirnesC2 1 IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
MirnesC2 Posted May 20, 2013 Author Share Posted May 20, 2013 (edited) Comically ironic, albeit hardly "intentional"... MirnesC2 - Your answers are in the previous posts, please don't read into the text things that are not there. Yo want to populate a 2D array using the syntax "array[row][column]". Do not exceed the boundaries of any subscripts (your last error). There are thousands of examples of 2D arrays on the forum. Put something together, identify exactly what the problems are and you will get all the help you need. kylomasYeah, maybe you're right I kinda feel as if I have been doing that lately.. I don't know why. I don't find offense in my replies, yet someone else always does. It might just be because of where I am from. You get something slightly sarcastic, so you dish out something slightly sarcastic. And in the end no one takes offense. Here it seems to get people's panties in a bunch.I managed to figure out how to do it in multiple lines.#include <Array.au3> Local $data[10][3] For $i = 0 To 10-1 Step +1 $data[$i][0] = 1987 $data[$i][1] = "Tooth Brush" $data[$i][2] = "$3.00" Next _ArrayDisplay($data)I was hoping to accomplish it with a single line like...#include <Array.au3> Local $data[10][3] For $i = 0 To 10-1 Step +1 $data[$i] = [1398, "Toothbrush", "$3.00"] Next _ArrayDisplay($data)But can't seem to figure out the error im making?It's not that big of deal though I guess. And thank you jdelaney for the example! Edited May 20, 2013 by MirnesC2 Link to comment Share on other sites More sharing options...
Solution jdelaney Posted May 20, 2013 Solution Share Posted May 20, 2013 You can do two liners, but that's creating array of arrays, and not a 2d array. Local $data[10] For $i = 0 To UBound($data)-1 Local $array[3] = [1398, "Toothbrush", "$3.00"] $data[$i] = $array Next MirnesC2 1 IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
MirnesC2 Posted May 20, 2013 Author Share Posted May 20, 2013 (edited) You can do two liners, but that's creating array of arrays, and not a 2d array.Local $data[10] For $i = 0 To UBound($data)-1 Local $array[3] = [1398, "Toothbrush", "$3.00"] $data[$i] = $array NextOohhh okay I see now. Thank you! That solves it P.S. Diggin the new "Mark solved" feature. Edited May 20, 2013 by MirnesC2 Link to comment Share on other sites More sharing options...
jdelaney Posted May 20, 2013 Share Posted May 20, 2013 (edited) here is a one liner from the helpfile(also an array of arrays): Local $data[10] For $i = 0 To UBound($data)-1 $data[$i] = StringSplit("Abe|Jack|Bobby|Marty", "|",2) Next Edited May 20, 2013 by jdelaney MirnesC2 1 IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
kylomas Posted May 20, 2013 Share Posted May 20, 2013 ...or just create a common 2D array... #include<array.au3> $data = '1234,bottle,5.00|2345,widget,19.00|3456,17.50,boat|4567,something else,priceless' local $aTmp1 = stringsplit($data,'|',2) Local $adata[ubound($aTmp1)][3] For $i = 0 To UBound($adata)-1 $aTmp2 = stringsplit($aTmp1[$i],',',2) for $j = 0 to ubound($adata,2) - 1 $adata[$i][$j] = $aTmp2[$j] next Next _arraydisplay($adata) kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
kylomas Posted May 20, 2013 Share Posted May 20, 2013 @jdelaney - I could not figure out how to address the array elements in your array of arrays directly. The closest I can come is using a temp array like this Local $data1[10] For $i = 0 To UBound($data1)-1 Local $array1[3] = [1398, "Toothbrush", "$3.00"] $data1[$i] = $array1 Next ; iterate $data1 local $aTmp3 for $1 = 0 to ubound($data1) - 1 $aTmp3 = $data1[$1] for $2 = 0 to ubound($atmp3) - 1 ConsoleWrite($atmp3[$2] & @LF) next next Do you know how to address them directly? kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill 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