• 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: String to sum
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: String to sum


  • Subject: Re: String to sum
  • From: Paul Berkowitz <email@hidden>
  • Date: Tue, 12 Oct 2004 09:47:36 -0700

On 10/12/04 9:22 AM, "Mr Tea" <email@hidden> wrote:

>
> Is there a significant overhead or delay associated with 'run script...'?

Yes. As for any osax call, or rather more than some. If you use it in a
repeat loop, a script will be appreciably slower. If you can find a way to
avoid it, do so. For example, if your operations will always be addition of
two operands, you could


set theString to "4 + 5"
set theResult to my AddOperands(theString)

to AddOperands(aString)
    set AppleScript's text item delimiters to {" + "}
    set {operand1, operand2} to text items of aString
    set AppleScript's text item delimiters to {""}
    --shouldn't even need a handler to trim leading and trailing white space
    set set {operand1, operand2} to {operand1 as number, operand2 as number}
    set theResult to operand1 + operand2
    return theResult
end AddOperands



You can also have routines for subtraction, multiplication, division,
exponents, and whatever other string mathematical operators you know might
occur in the string. You'll need tests for strings with no such operators
(and more than one, if possible).

These will be a lot faster than run string.

--
Paul Berkowitz


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: String to sum
      • From: Martin Orpen <email@hidden>
    • IS: Bug in String Coercions containing Operators? -- WAS: Re: String to sum
      • From: Johnny AppleScript <email@hidden>
References: 
 >Re: String to sum (From: Mr Tea <email@hidden>)

  • Prev by Date: Re: String to sum
  • Next by Date: Mail.app plugin based on email address
  • Previous by thread: Re: String to sum
  • Next by thread: IS: Bug in String Coercions containing Operators? -- WAS: Re: String to sum
  • Index(es):
    • Date
    • Thread