First i created 20 text boxes and named them with numbers 1-20
second, I entered the value of their name into the text boxes (entered 1 in the text box named 1, 2 into the text box named 2 etc.)
then i scripted this code into a button
Code: Select all
on mouseUp
local tVar
repeat with x = 1 to 20
do "put field " &x& " into tVar"
put tVar into myArray[(100 + the value of x)]
end repeat
combine myArray using tab
answer myArray
end mouseUp
instead, the numbers were jumbled in an order of 1, 6 ,11,16,17,12,7,2,18,13,8,3,19,14,9,4,20,15,10,5
i fixed this problem by adding the word field at the beginning of each fields name ( now field2 field2 field3 etc) and adding an extra field into the do command. the code now looked like this
Code: Select all
on mouseUp
local tVar
repeat with x = 1to 20
do "put field field" &x& " into tVar"
put tVar into myArray[(100 + the value of x)]
end repeat
combine myArray using tab
answer myArray
end mouseUp
what i don't understand is why the code didn't work the first time. I suspect that it might have something to do with the order in which the boxes were created. Which, due to copying and pasting, is not the same order in which they were named.
Any light to shed?