Jump to content

Recommended Posts

Posted

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"
Posted (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 by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

  • Moderators
Posted

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:

  Reveal hidden contents

 

Posted (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 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

Posted

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"] _
     ]

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...