Darknvader500a Posted June 12, 2010 Share Posted June 12, 2010 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 More sharing options...
Developers Jos Posted June 12, 2010 Developers Share Posted June 12, 2010 (edited) Something like this? For $x = 0 to ubound($nameArray)-1 $resultsArray[0][$x] = $nameArray[$x] Next Edited June 12, 2010 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 More sharing options...
Moderators SmOke_N Posted June 12, 2010 Moderators Share Posted June 12, 2010 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 More sharing options...
Darknvader500a Posted June 12, 2010 Author Share Posted June 12, 2010 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 Link to comment Share on other sites More sharing options...
Darknvader500a Posted June 12, 2010 Author Share Posted June 12, 2010 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 More sharing options...
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