corrado33 Posted January 22, 2009 Share Posted January 22, 2009 Ok so I'm new here, but I did search for my problem and I couldn't seem to find it. Ok so this is really dumb if this isn't possible. I want to fill an array from inside a for loop, however the program won't let me specify the array place with a variable. Ex. Array[1] --> works ok, however, Array[$i] does not work. Why is this and how do I make it work. And no I didn't name the array "Array" it's just for example. TIA Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted January 22, 2009 Share Posted January 22, 2009 It is fully possible, there must be something else that is wrong with your script, see this example. #include <Array.au3> Local $aArray[11] For $X = 0 To 10 $aArray[$X] = Random() Next _ArrayDisplay($aArray) If you need further help please write a small (working=runnable) script and tell more exactly what the problem is .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
bo8ster Posted January 22, 2009 Share Posted January 22, 2009 It depends on how the array is created. Are the number of defined or is it returned from a function? Posting code helps to see whats going on. Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
corrado33 Posted January 22, 2009 Author Share Posted January 22, 2009 It is fully possible, there must be something else that is wrong with your script, see this example. #include <Array.au3> Local $aArray[11] For $X = 0 To 10 $aArray[$X] = Random() Next _ArrayDisplay($aArray) If you need further help please write a small (working=runnable) script and tell more exactly what the problem is Thanks so much!! It was the way I was declaring the array, I had no idea about the "Local" statement. Thanks again! Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted January 22, 2009 Share Posted January 22, 2009 Thanks so much!! It was the way I was declaring the array, I had no idea about the "Local" statement. Thanks again!Using Local, Global or Dim is highly dependant on the situation, there are two pages in the helpfile about them which I highly recommend that you read if you haven't already. page1, page2By searching the forum (you have the search-button on the top right) you can also find lots of discussions about the subject, some examples= thread1, thread2BTW, welcome to the forum!! (just noticed that post earlier was your first ) .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface 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