Your mod wants to show a series of results in a scrollable list it looks like. It needs that list.
You may want to consider making a table that stores the results instead of calculating result on the fly. This will be *a lot* better performance-wise if it takes a lot to get a result. Every time the scroll thumb is moved all visible entries will need recalcuated if you don't.
edit: Bunch of stuff removed that will just confuse things I think. After rereading your posts it sounds like whatever makes "result" does something intensive. Can you post how "result" is created? Turning "result" into a list is the primary purpose of that function.
It's possible that it's something that shouldn't be done in a scroll frame update (which gets called a bazillion times). Does it target anything? Does it assist or switch gear or anything else that's intensive?
As an aside, to create an array/table/list (in lua they're all the same really):
Say this is a hypothetical function that defines "result" your global variable. (btw I strongly recommend making "result" local to the mod or changing the name. I know of two mods that also use "result", tho theirs are local)
Code:
function Do_Whatever_Calculates_Result()
result = "Random test "..math.random(100)
end
To add 40 "result" to a list:
Code:
myList = {}
for Item=1,40 do
Do_Whatever_Calculates_Result()
table.insert(myList,result)
end
That will make a list that looks like:
myList = {
["1"] = "Random test 23",
["2"] = "Random test 83",
["3"] = "Random test 49",
...
["40"] = "Random test 12"
}