I have an application that has 73 text fields (it’s a Time Sheet type of application).
These 73 text fields are broken into sub groups of 30, 25 and 18 and the 25 is further broken down into sub groups of 5. Each subgroup has all it’s entries totaled into another text field.
It functions this way:
I have a list with the name of each text field in a group so there are 7 lists that hold 30, 5, 5, 5, 5, 5, and 18 items respectively. On end editing I then check to see which lists contains the object name through an if then else statement.
Looks like this:
if list1 contains thisTextObject then
–>do stuff
else if list2 contains thisTextObject then
–>do stuff
and so on…
once a match is found I set a var with a 0 value, then loop through the list items, use the item name to retrieve a text field value and add it’s value to the var I just set to get the total for that section.
Here’s a snippet of how that works:
else if magTimeArray contains thisTextBox then
set newMagTotals to 0
repeat with thisMag in magTimeArray
set textBoxValue to contents of text field thisMag
set newMagTotals to newMagTotals + textBoxValue
end repeat
set contents of text field “allMagTotals” to newMagTotals
…
this works fine but the performance is really slow, even on my dual core intel there’s noticeable delays. I think the culprit here is AppleScript and it being just slow but I’m surprised that it would chug while performing two, what I think are, relatively small loops (initially through all the lists till a match is found, which could be 70 odd items and then through the individual list where the match was found, which would be no more than 30 items). I had read that referencing the list can improve speed significantly but we tried that with no difference, which isn’t to say we didn’t implement that wrong.
I tried it like this:
repeat with thisMag in my magTimeArray
Searching through the archives here I came across a few post, one in particular about buttons and a large if else statement where the suggestions were to just call in scripts but that one involved hundreds of conditionals, mine is only seven.
Any advice would be greatly appreciated