# I'm Stupid

## Recommended Posts

Could someone please tell me what is wrong with this:

```Global \$nameArray[3]=["hello", "there", "why"]
Global \$resultsArray[3][20]

.... then latter in another function

\$resultsArray[0] = \$nameArray```

I am making a little scipt that takes an array of words \$nameArray, makes some random permutations on them and then outputs to the different permutations to the \$resultsArray. So I want \$resultsArray to looks like this

\$resultsArray =

["hello", "there", "why"],

["modifiedhello", "modifiedThere", "modifiedwhy"],

["moreModifiedHello", "moreModifiedTHere", etc....

Sorry about the dumb nature of this question, but I just can not seem to figure it out. I keep getting 'Array variable has incorrect number of dimensions'

I could do something like this:

\$resultsArray[0][0] = \$nameArray[0]

\$resultsArray[0][1] = \$nameArray[1]

\$resultsArray[0][2] = \$nameArray[2]

but that will end up being too much work.

##### Share on other sites

Something like this?

```For \$x = 0 to ubound(\$nameArray)-1
\$resultsArray[0][\$x] = \$nameArray[\$x]
Next```
Edited by Jos

Live for the present,
Dream of the future,
Learn from the past.

##### Share on other sites

Could someone please tell me what is wrong with this:

```Global \$nameArray[3]=["hello", "there", "why"]
Global \$resultsArray[3][20]

.... then latter in another function

\$resultsArray[0] = \$nameArray```

You declared your \$resultsArray with two dimensions: \$resultsArray[3][20]

Then you try to access it as if it were one dimension: \$resultsArray[0]

That's why you get the incorrect number of dimensions error.

----

For the other part of your question, Jos has provided a simple 3 line solution, but won't help your issue unless you call it with the right number of dimensions.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

##### Share on other sites

Something like this?

```For \$x = 0 to ubound(\$nameArray)-1
\$resultsArray[0][\$x] = \$nameArray[\$x]
Next```

Thank for the information. I appreciate it. For some reason I though you could assign arrays like that. Maybe I am thining to much in c

##### Share on other sites

You declared your \$resultsArray with two dimensions: \$resultsArray[3][20]

Then you try to access it as if it were one dimension: \$resultsArray[0]

That's why you get the incorrect number of dimensions error.

----

For the other part of your question, Jos has provided a simple 3 line solution, but won't help your issue unless you call it with the right number of dimensions.

Got you, I guess I was thinking that \$resultsArray[0] would could just be a pointer to the rest of the array or something. Thanks for the info. Now I understand that autoIt does not work like that.

## Create an account

Register a new account

×

• Wiki

• Back

• Git