• 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
'my' problem is your problem: it chokes without 'my'! BUG
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

'my' problem is your problem: it chokes without 'my'! BUG


  • Subject: 'my' problem is your problem: it chokes without 'my'! BUG
  • From: Harald E Brandt <email@hidden>
  • Date: Tue, 25 Jan 2011 18:39:58 +0100

Consider the following very simple script:

property theData : {}
set theFile to (choose file with prompt "Choose tab-delimited file:")

set theParas to paragraphs of (read theFile as text)
repeat with aRow in theParas
set end of my theData to {contents of aRow} -- using 'my' is absolutely vital for large files!!
end repeat

If run with a text file of 10 000 lines, it takes about 12.5 seconds on a MacBook Pro 2.2 GHz Core 2 duo, 4 GB, SSD 200 GB.
If you remove the 'my', it won't terminate!  Nasty!

(Ok, I didn't wait for hours, but for minutes.)

The file is a very simple text file with all rows equal, being:
"AP name 0 0 A longish comment about it all"
with tabs on each side of the '0', so there are 4 columns, a total of 42 characters per line.

Originally, the script took the text items of this (with tab as separator) but I discovered that the bug was just as bad without picking text items; all it takes is making a list of lists.
The reading of the file into paragraphs only takes about 0.15 seconds, so all time is spent in the repeat loop.

If run on a 1000-line file, it works better: it will terminate less than 0.2 seconds with the 'my', and about 0.7 seconds without the 'my'.

So, despite no handler or script object is involved, the 'my' is needed, and it is also needed if you wrap it into a handler.


______heb____________________________
Harald E Brandt     http://bragit.com

 _______________________________________________
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

  • Prev by Date: Is Image Disk Trash Empty?
  • Next by Date: Re: Is Image Disk Trash Empty?
  • Previous by thread: Re: Is Image Disk Trash Empty?
  • Next by thread: Re: 'my' problem is your problem: it chokes without 'my'! BUG
  • Index(es):
    • Date
    • Thread