New topic: Populating an Array
<http://forums.realsoftware.com/viewtopic.php?t=33076> Page 1 of 1 [ 1 post ] Previous topic | Next topic Author Message rlitchfield Post subject: Populating an ArrayPosted: Sat Mar 20, 2010 11:09 am Joined: Thu Feb 25, 2010 4:50 pm Posts: 22 Back for some help. I'm trying to dynamically populate an array and I'm running into trouble. The objective is to build a randomizer using the array shuffle. While I know there are better ways of doing this, I'm building this in order to get to know the language better. Code:Protected Function Randomizer(low as Integer, high as Integer) As Integer //Pick a random number dim i as integer //start array at 0 and move up dim i2 as integer // work my way through the for loop dim a(-1) as integer //Array i = 0 for i2=low to high a(i) = low //Get out of bounds exception error low = low+1 i = i+1 next a.Shuffle /randomize the contents return a(0) End Function Can someone give me a hint as to what I'm doing wrong? Thank you, RJL Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 1 post ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
