Trouble using repeat with loops and a counter variable
Posted: Mon Feb 03, 2014 7:56 pm
Hi all,
I'm working on making a repeat loop to put items into an array. I'm using a repeat with loop and want to use the counter variable to also tell the program what key to store the data in within the array.
It will look something like this:
I've tested that tCurrFiles actually has the files I want stored within it and that it will put a line from tCurrFiles into targetArray[1] and then show that file from targetArray[1] in an image. See below for how I tested this.
This results in a picture from the folder I pass the program from an earlier set of code being displayed in "Image 1" and it does change every time I run this test.
I guess my question is does an array (or other data and control structures; I've had a similar problem with a get random type structure) use the x in the same way it does the one--as in it reads the x as the key--or will it use the data stored within x as the key--in this case the numbers 1 through 12?
Thank you so much for your help!
Jeff
I'm working on making a repeat loop to put items into an array. I'm using a repeat with loop and want to use the counter variable to also tell the program what key to store the data in within the array.
It will look something like this:
Code: Select all
put 1 into y
repeat with y = 1 to 12
put any line of tCurrFiles into targetArray[y]
delete current line of tCurrFiles
add 1 to y
end repeat
Code: Select all
put any line of tCurrFiles into targetArray[1]
delete current line of tCurrFiles
set the filename of img "Image 1" to targetArry[1]
I guess my question is does an array (or other data and control structures; I've had a similar problem with a get random type structure) use the x in the same way it does the one--as in it reads the x as the key--or will it use the data stored within x as the key--in this case the numbers 1 through 12?
Thank you so much for your help!
Jeff