Jump to content

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.

Thanks for any help you can provide.

Link to comment
Share on other sites

  • Developers

Something like this?

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

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.

Link to comment
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.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...