Breaking up a long string
Breaking up a long string
- Subject: Breaking up a long string
- From: Joseph Weaks <email@hidden>
- Date: Wed, 18 Jun 2003 23:48:35 -0500
Any suggestions on a better way to do this?
set thisParagraph to "A really long paragraph that I need to break into
longer chunks..."
set maxParagraphLength to 400
repeat with x from 1 to (length of thisParagraph) by maxParagraphLength
try
set thisChunk to (characters x thru (x + maxParagraphLength)) of
thisParagraph as string
on error
set thisChunk to (characters x thru (length of eachParagraph)) of
thisParagraph as string
end try
-- do stuff with thisChunk
end repeat
Thanks,
Joe
P.S. The "as string" was causing the app that calls this script to crash.
It took me awhile to find this culprit, which was happening because I had
earlier changed Applescript's tid WITHOUT restoring previous value. I
thought I'd give it a try as per the recent discussion. No more. I'm a
born again save and restorer. The argument that it adds alot of wasted
code doesn't resonate with me, since I'd have to set the tid's before
EVERY list/string coercion if I stayed with that approach. (ie. the above
code snippet would have two extra lines setting the tid's to "")
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.