Jump to content
Sign in to follow this  
Darknvader500a

I'm Stupid

Recommended Posts

Darknvader500a

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.

Share this post


Link to post
Share on other sites
Jos

Something like this?

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

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
SmOke_N

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 this post


Link to post
Share on other sites
Darknvader500a

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 this post


Link to post
Share on other sites
Darknvader500a

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.

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.