• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Questions on approach
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Questions on approach


  • Subject: Re: Questions on approach
  • From: Brian Christmas <email@hidden>
  • Date: Tue, 16 Nov 2010 14:02:26 +1100


On 16/11/2010, at 12:41 PM, Alex Zavatone wrote:

I'm using System Events to get access to the UI Elements of a table in a scrolling field in an app.   There are 4 columns in the table.  I'm able to access it just fine, but performance starts to crater as some time between one and one thousand rows in it.

So, I'm wondering about approaches here in accessing the data structure.    I've already tried duplicating it and accessing the duplicate but that doesn't seem to help.

Anyway, I'm wondering about anyone's approaches in speeding up data access in these cases.

This is what I'm trying:

set myWindow to window 1
copy table 1 of scroll area 1 of myWindow to myTable
set myRows to the number of rows of myTable
set myList to {}
repeat with myIndex from 1 to myRows
set myRow to entire contents of row myIndex of myTable
set myValue to the value of item 4 of myRow


It's taking about 2 to 3 seconds to get myValue.  Does anyone have any approaches that might speed this up a tad?  Thaaaanks, 

- Alex Zavatone

G'day Alex

I struck a similar problem with Mail.

I had very long emails with a certain character in them "∎" that I wanted to color, and had a reference copy as a string to get the positions of the characters (as you do with the variable 'MyTable').

The trouble wasn't setting the color in the mail messages, the trouble was reading the x th value of the string where x was large.

So, I broke the string variable into chunks, and read each chunk. This is taken direct from my code. Hope it gives you some ideas. Doing this spend my coloring process from over an hour to mere seconds.

ContentCount is the length of the variable ie in your case, mytable

if colorFlag then
set theCycleLoop to 400
if theCycleLoop > ContentCount then set theCycleLoop to ContentCount
try
repeat with x from 1 to ContentCount by theCycleLoop
set y to x + theCycleLoop
if y ≥ ContentCount then set y to ContentCount
set tempstring to characters x thru y of the_content as text
set thePosition to 0
set yy to (count of tempstring)
repeat with xxx from 1 to yy
if character xxx of tempstring = "∎" then
if thePosition = 0 then set thePosition to xxx
else
set color of character (x + xxx) to theTextColor
if thePosition ≠ 0 then
set color of characters (x + thePosition - 2) thru (x + xxx - 1) of content to TheColor
set thePosition to 0
end if
end if
end repeat
if thePosition ≠ 0 then set color of characters (x + thePosition - 1) thru (x + xxx - 1) of content to TheColor
end repeat
on error errmsg
tell application "Finder"
say "error"
activate
display dialog errmsg
end tell
end try
end if


And what, you ask, was the beginning of it all?
And it is this......
Existence that multiplied itself
For sheer delight of being
And plunged with numberless trillions of forms
So that it might
find
itself
innumerably

Sri Aurobindo





 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Questions on approach
      • From: Christopher Stone <email@hidden>
References: 
 >Questions on approach (From: Alex Zavatone <email@hidden>)

  • Prev by Date: Re: Changing voice in VoiceOver
  • Next by Date: Re: Questions on approach
  • Previous by thread: Re: Questions on approach
  • Next by thread: Re: Questions on approach
  • Index(es):
    • Date
    • Thread