Blueman Posted June 11, 2015 Share Posted June 11, 2015 Hi all,I think i have a silly question, but iam stuck and i need some help I have the following code;; Article Global $configfile_artikel[25] local $cx = 0 Do Local $configfile_artikel[$cx] = StringSplit($configfile_contents[$cx+2], "=", 0) $cx = $cx + 1 Until $cx = 23 EndIfBut if i execute this code, i will get an error; Missing subscript dimensions in "Dim" statement. I have tried several codes, but i need to create an array in an array and it is failing,. Can you guys help me with this? Thanks! Link to comment Share on other sites More sharing options...
Exit Posted June 11, 2015 Share Posted June 11, 2015 Please show us a real runnable reproducer with all data and variables. App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
SadBunny Posted June 11, 2015 Share Posted June 11, 2015 (edited) Could you post a working reproducer? That one is broken on many points...Here is a working example of arrays in arrays:#include <Array.au3> Global $firstInner[2] = ["hi", "bye"] Global $secondInner[2] = ["one", "two"] Global $outer[2] = [$firstInner, $secondInner] For $ar In $outer _ArrayDisplay($ar) Next/edit: exit beat me Edited June 11, 2015 by SadBunny Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
Blueman Posted June 11, 2015 Author Share Posted June 11, 2015 (edited) Hi all,Thanks for the examples, here is a complete script!expandcollapse popup#include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <GUIConstants.au3> #include <Crypt.au3> #include <ColorConstants.au3> #include <GUIConstantsEx.au3> #include <ComboConstants.au3> #include <Array.au3> #include <String.au3> #include <ProgressConstants.au3> #include <IE.au3> #include <WindowsConstants.au3> #include <BlockInputEx.au3> #include <File.au3> #include <APIConstants.au3> #include <WinAPIEx.au3> #include <GuiButton.au3> ; Bestaat config file? Local $iFileExists = FileExists("favotool.conf") If $iFileExists = 1 Then ; Kijk of configfile bestaat, zoja roep gegevens op Local $configfile = FileRead("favotool.conf") Local $configfile_contents = StringSplit($configfile, @CRLF, 0) ; Artikelen Global $configfile_artikel[25] local $cx = 0 Do Local $configfile_artikel[$cx] = StringSplit($configfile_contents[$cx+2], "=", 0) $cx = $cx + 1 Until $cx = 23 EndIf :favotool.conf Magazijnnummer=435 0=~~~~4 1=~~~~4 2=~~~~4 3=~~~~4 4=~~~~4 5=~~~~4 6=~~~~4 7=~~~~4 8=~~~~4 9=234243~11111~TESTING1~3~1 10=~~~~4 11=~~~~4 12=~~~~4 13=~~~~4 14=435435~444~TESTING2~2~4 15=~~~~4 16=~~~~4 17=~~~~4 18=~~~~4 19=~~~~4 20=~~~~4 21=~~~~4 22=~~~~4 I am trying to call a variable with;$xc = 0 Do GUICtrlCreateInput($configfile_artikel_output[$xc][2],30,$height,90,20,0x0001) $xc = $xc + 1 Until $xc = 23 Edited June 11, 2015 by Blueman Link to comment Share on other sites More sharing options...
Exit Posted June 11, 2015 Share Posted June 11, 2015 Sorry, that's no reproducer App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 11, 2015 Moderators Share Posted June 11, 2015 Blueman,I have no idea why you are using all those includes - here is a version which seems to work:expandcollapse popup#include <Array.au3> #include <File.au3> #include <StringConstants.au3> ; Bestaat config file? Local $iFileExists = FileExists("favotool.conf") If $iFileExists = 1 Then ; Kijk of configfile bestaat, zoja roep gegevens op Local $configfile = FileRead("favotool.conf") Local $configfile_contents = StringSplit($configfile, @CRLF, $STR_ENTIRESPLIT) ; If you want each line in an element you need the $STR_ENTIRESPLIT flag _ArrayDisplay($configfile_contents, "Your way", Default, 8) ; But it is much easier to do this Local $configfile_contents _FileReadToArray("favotool.conf", $configfile_contents) _ArrayDisplay($configfile_contents, "Easy way", Default, 8) ; Artikelen Global $configfile_artikel[25] Local $cx = 0 Do $configfile_artikel[$cx] = StringSplit($configfile_contents[$cx + 2], "=") $cx = $cx + 1 Until $cx = 23 ; The array holding the arrays _ArrayDisplay($configfile_artikel, "", Default, 8) ; An internal array _ArrayDisplay($configfile_artikel[9], "", Default, 8) EndIfM23 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...
mikell Posted June 11, 2015 Share Posted June 11, 2015 Blueman,2 errors made your code wrong :- as Melba said, StringSplit(..., @CRLF, 1) it needs the flag 1 ( = $STR_ENTIRESPLIT) because CRLF contains 2 chars (CR+LF)- Local $configfile_artikel[$cx] (in the Do loop) means a declaration so you get the "Missing subscript dimensions" errorUse flag 1 in the StringSplit, remove the "Local" and the code works Link to comment Share on other sites More sharing options...
Blueman Posted June 11, 2015 Author Share Posted June 11, 2015 (edited) Thanks guys, works like a charm!Now i have to figure out how to get the value from eg; $configfile_artikel[$cx][2]But i think thats simple Thanks again!EDIT: I used _ArrayToString($configfile_artikel[$cx], "", 2, 2) For that Edited June 11, 2015 by Blueman Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 11, 2015 Moderators Share Posted June 11, 2015 Blueman,how to get the value from eg; $configfile_artikel[$cx][2]($configfile_artikel[$cx])[2]Note the ( ) around the first section.M23 Radiance 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...
Blueman Posted June 11, 2015 Author Share Posted June 11, 2015 Ah Melba23,Thats a lot easy'er!Thanks Link to comment Share on other sites More sharing options...
UEZ Posted June 11, 2015 Share Posted June 11, 2015 Here another example:#AutoIt3Wrapper_Version=b #include <Array.au3> Global $sText = "This is an example for array in an array :-)" Global $aArray_Main[2] = ["Index = 0", StringSplit($sText, " ", 2)] ConsoleWrite("Modifying value " & ($aArray_Main[1])[9] & @CRLF) _ArrayMod($aArray_Main[1], ";-)", 9) ;modify 9th entry in nested array :-) -> ;-) _ArrayDisplay($aArray_Main[1], "Sub Array") Func _ArrayMod(ByRef $aArray, $vValue, $iIndex) ;no error checks! $aArray[$iIndex] = $vValue EndFunc Radiance 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Radiance Posted June 12, 2015 Share Posted June 12, 2015 I didn't know that it's possible to put an array in an array.Are there any benefits using this method instead of 2D-Arrays? Link to comment Share on other sites More sharing options...
BrewManNH Posted June 12, 2015 Share Posted June 12, 2015 Are there any benefits using this method instead of 2D-Arrays?You generally don't want to do this, as it makes things harder because accessing elements in the internal array isn't as easy to code as accessing 2D array elements. Radiance 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
czardas Posted June 12, 2015 Share Posted June 12, 2015 I think it's partly a design choice. Suppose you intend to Redim the sub-arrays - using a 2D array could turn out to be a nightmare in this case. In most normal cases I would prefer to use a single multidimensional array. Radiance 1 operator64 ArrayWorkshop 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