lavascript Posted February 28, 2013 Posted February 28, 2013 So... this doesn't work. #include <Array.au3> Local $aTest1[3] = ["Thing1 Thing2 Thing3","Thing4 Thing5 Thing6","Thing7 Thing8 Thing9"] Local $aTest2[3][3] For $i = 0 to UBound($aTest1) $aTest2[$i] = StringSplit($aTest1[$i]," ") Next _ArrayDisplay($aTest2) It seems that a 2-dimensional array is completely different from an array in which every element is an array. The result I'm hoping for is: $aTest2[0][0] = "Thing1" $aTest2[0][1] = "Thing2" $aTest2[0][2] = "Thing3" $aTest2[1][0] = "Thing4" $aTest2[1][1] = "Thing5" $aTest2[1][2] = "Thing6" $aTest2[2][0] = "Thing7" $aTest2[2][1] = "Thing8" $aTest2[2][2] = "Thing9"
guinness Posted February 28, 2013 Posted February 28, 2013 (edited) #include <Array.au3> Local $aArray_1[3] = ['Thing1 Thing2 Thing3', 'Thing4 Thing5 Thing6', 'Thing7 Thing8 Thing9'] Local Const $iUBound = UBound($aArray_1) Local $aArray_2[3][3], $aSplit = 0 For $i = 0 To $iUBound - 1 $aSplit = StringSplit($aArray_1[$i], ' ', 2) For $j = 0 To UBound($aSplit) - 1 $aArray_2[$i][$j] = $aSplit[$j] Next Next _ArrayDisplay($aArray_2) Edited February 28, 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
Moderators Melba23 Posted February 28, 2013 Moderators Posted February 28, 2013 lavascript, You need to extract the elements before loading them into the array: #include <Array.au3> Local $aTest1[3] = ["Thing1 Thing2 Thing3", "Thing4 Thing5 Thing6", "Thing7 Thing8 Thing9"] Local $aTest2[3][3] For $i = 0 To UBound($aTest1) - 1 $aTemp = StringSplit($aTest1[$i], " ", 2) For $j = 0 To UBound($aTemp) - 1 $aTest2[$i][$j] = $aTemp[$j] Next Next _ArrayDisplay($aTest2) All clear? M23 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
Nessie Posted February 28, 2013 Posted February 28, 2013 (edited) Try this: #include <Array.au3> Local $aTest1[3] = ["Thing1 Thing2 Thing3","Thing4 Thing5 Thing6","Thing7 Thing8 Thing9"] Local $aTest2[3][3] For $i = 0 to UBound($aTest1) - 1 $split = StringSplit($aTest1[$i]," ", 2) For $x = 0 To UBound($split) - 1 $aTest2[$i][$x] = $split[$x] Next Next _ArrayDisplay($aTest2) Hi! Edited February 28, 2013 by Nessie 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
lavascript Posted February 28, 2013 Author Posted February 28, 2013 Thanks! I knew I could do it with nested For loops, that just didn't seem like the "right" way.
GMK Posted February 28, 2013 Posted February 28, 2013 Local $aTest1[3][3] = [["Thing1", "Thing2", "Thing3"], ["Thing4", "Thing5", "Thing6"], ["Thing7", "Thing8", "Thing9"]] ...or to make it more readable:Local $aTest1[3][3] = [ _ ["Thing1", "Thing2", "Thing3"], _ ["Thing4", "Thing5", "Thing6"], _ ["Thing7", "Thing8", "Thing9"] _ ]
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