Tioner Posted March 6, 2013 Share Posted March 6, 2013 so I wanted to create a multi dimensional array using a loop and stringsplit function, it'd be all great but if the loop goes on over 100 times, the script wont run and will return the following error: ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded. for $i = 1 to 100 $array2 = stringsplit($array[$i],",") Next the loop as it is wont let the script compile or even run, if I decrease the 100 to 99 however, the script runs fine. the thing is I need to do over 5000 loops for it to be completed. any ideas? kind regards. Link to comment Share on other sites More sharing options...
jdelaney Posted March 6, 2013 Share Posted March 6, 2013 (edited) sounds like the UBound of your array is 99 (100, but starts at 0), not sure where you are pulling 5000 from using array of arrays: Local $array2[UBound($array)] for $i = 0 to UBound($array)-1 $array2[$i] = stringsplit($array[$i],",") Next or search forum for csv splitter, tons out there Edited March 6, 2013 by jdelaney 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...
PhoenixXL Posted March 7, 2013 Share Posted March 7, 2013 Array variable has incorrect number of subscripts or subscript dimension range exceeded.I'm sure there is some error in your coding. Please submit the full code of the Array My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
Tioner Posted March 7, 2013 Author Share Posted March 7, 2013 Thanks for the reply, and sorry for little information on my issue. Array[$i] has over 5000 entries so I thought I need to loop it 5000 times to create a 2d array. I'll put the code for both loops when I get home. Link to comment Share on other sites More sharing options...
guinness Posted March 7, 2013 Share Posted March 7, 2013 Look at UBound, ReDim, @error and the Array section in the AutoIt Wiki. 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...
Tioner Posted March 7, 2013 Author Share Posted March 7, 2013 #include #include #include #include #include #include global $i $Form1 = GUICreate("Loading", 460, 177, -1, -1) $Pic1 = GUICtrlCreatePic($pic, 0, 0, 460, 150, BitOR($SS_NOTIFY, $WS_GROUP)) $Progress1 = GUICtrlCreateProgress(2, 152, 456, 17) GUICtrlSetData(-1, $i) GUISetState(@SW_SHOW) $file = "base.txt" $lines = _FileCountLines($file) $line = filereadline($file,1) $string1 = stringsplit($line,",") $string = $string1[0] local $array[$lines], $i, $array2[$lines] for $i = 1 to $lines $array[$i-1] = filereadline($file, $i) $percent = ($i/$lines) $percent = $percent * 100 GUICtrlSetData($Progress1, $percent) next for $i = 1 to $lines-1 $percent = ($i/$lines) $percent = $percent * 100 GUICtrlSetData($Progress1, $percent) $array[$i-1][$i-1] = stringsplit($array[$i],",") Next GUISetState(@SW_HIDE) msgbox(0,"",$array[3][1]) so here's the code for the entire script so far. I'm kinda struggling with the 2D array and how it could be built with 2 loops. the file is also 2D, it contains columns and rows, I'm ill right now and I cant think bright enough to figure it out myself, so I'd love to get a tip from you guys what might be wrong. the most concerning question is about stringsplit() function, if there's already an array, (like so: $array[$i]) will it write the split elements to the first array or create a multidimenshional array out of the 1D array? so the code would look like so: $array[$i-1] = stringsplit($array[$i],",") or is this part correct, and it will assign the elements to the second square bracket [$i-1] $array[$i-1][$i-1] = stringsplit($array[$i],",") thanks for your time and I hope we can figure it out together. Link to comment Share on other sites More sharing options...
Nessie Posted March 7, 2013 Share Posted March 7, 2013 Can you provide to us the file base.txt? Hi! My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s). My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all! My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file Link to comment Share on other sites More sharing options...
czardas Posted March 8, 2013 Share Posted March 8, 2013 (edited) Here's a method: #include <Array.au3> ; Needed for _ArrayDisplay $sTest = "0,1,2|3,4,5,6|7,8,9" $a2D = StringTo2dArray($sTest, "|", ",") _ArrayDisplay($a2D) Func StringTo2dArray($sString, $sDelim4Rows, $sDelim4Cols) Local $aArray = StringSplit($sString, $sDelim4Rows, 2) ; Split to get rows Local $iBound = UBound($aArray) Local $aRet[$iBound][2], $aTemp, $iOverride = 0 For $i = 0 To $iBound -1 $aTemp = StringSplit($aArray[$i], $sDelim4Cols) ; Split to get row items If Not @error Then If $aTemp[0] > $iOverride Then $iOverride = $aTemp[0] ReDim $aRet[$iBound][$iOverride] ; Add columns to accomodate more items EndIf EndIf For $j = 1 To $aTemp[0] $aRet[$i][$j -1] = $aTemp[$j] ; Populate each row Next Next If $iOverride <= 1 Then $aRet = $aArray ; Array contains single row or column Return $aRet EndFunc ;==> StringTo2dArray Edited March 8, 2013 by czardas ss26 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